Queries (pull)
For when you want to pull data from Pitchly
Endpoints
Endpoint | Description |
Get all the databases that belong to an organization. | |
Get information about a specific database. | |
Get data rows from a database. | |
Get the number of rows in a result. | |
Get images and PPT asset for selected rows. |
databases
Gets all the databases that belong to an organization. If docDbOnly is true
, then only databases that have the Documents app installed will be returned.
You can get the organization ID from the URL address bar while logged into Pitchly. When inside the account, the URL will follow the pattern:
https://v2.pitchly.net/t/<ORGANIZATION_ID>/d/<DATABASE_ID>/a/<APP_ID>
With GraphQL, you can narrow down the properties you wish to receive in the result, such as only the fields
in the tables, or even just the name
and _id
. filters
and templates
, however, may require some more explanation.
filters
is an array of "Saved Filters" that have been saved in your Pitchly account in the left-hand pane to a database. It returns the name
of the filter and the filter
object that you can pass directly to the data
query to load results matching that filter.
templates
is an array of templates that live in the Documents app for this database. The path
of the template is a string value containing the stringified path to the template in the directory structure in the Documents app, where each folder is separated by " > ". For example, a template called "Foo" in the folder "Bar" would read Bar > Foo
. If the template is at the root directory, it would just read, Foo
. The name
property simply contains the name of the template, the equivalent of the last name shown in the path
.
Example result
Returns an array of databases in the specified organization. Each database has an _id
, name
, and an array of fields
. See the meaning of each field's properties here, and more information about field types.
database
Gets information about a specific database, including its fields.
You can get the database ID from the URL address bar while logged into Pitchly. When inside the account, the URL will follow the pattern:
https://v2.pitchly.net/t/<ORGANIZATION_ID>/d/<DATABASE_ID>/a/<APP_ID>
Example result
Returns the specified database. The database has an _id
, name
, and an array of fields
. See the meaning of each field's properties here, and more information about field types.
data
Gets data from a database.
You can get the database ID from the URL address bar while logged into Pitchly. When inside the account, the URL will follow the pattern:
https://v2.pitchly.net/t/<ORGANIZATION_ID>/d/<DATABASE_ID>/a/<APP_ID>
Example result
Returns an array of rows. Each row has an _id
and cols
for each column/field of data in the row. The data in each column can differ based on field type, but generally those variations will take place within the value
object. When value
is an object, it is guaranteed to at least always have a val
property.
When a value is empty, value
may either be null
(indicates "not set"), or value
may be an object where val
itself is null
(indicates "intentionally empty"). Read more about empty values.
You can also find all of the expected value object formats for each data type here.
Advanced data queries
The sample query above may work fine for very simple queries, but the data endpoint allows us to pass many more options to query very specific information. Below is a list of optional variables the data endpoint additionally accepts, beside a secretKey
and databaseId
.
Variable | Type | Description |
filter | object | Narrows rows by specifying filter criteria |
sort | object | Sorts rows in ascending or descending order by field ID, in the order specified |
limit | number | The maximum number of rows to return (default = 100) |
skip | number | Skips the first N number of rows in the result set (useful for pagination) |
in | array | Limit resulting rows to the row IDs specified in this array |
fields | array | Only return the fields in each row specified in this array of field IDs |
removedAt | boolean | Only returns rows in the trash |
search | string | Specifies a global search string where , is interpreted as and and | is interpreted as an or |
modifiedSince | string | Filters rows to only those created or updated since the date specified. Must be in the following format: |
Examples
Example 1 (simple)
Get rows where ID equals "order-2883"
Example 2 (relational)
Get rows in Orders where the Client's Name either contains "Michael" or "John". Note that the Client is a reference to the "Clients" database, which contains a field called "Name". Pitchly is unique in that you can filter data relationally, not unlike a traditional SQL database. The below pattern is also recursive, so you can filter across more than one table or relationship.
Since different field types accept different filter parameters, here is a list of all the possible filter parameters for each field type. They can be used within the filters
array.
Conjunctions can be used to perform AND or OR operations at each step of a filter. Different logical conjunctions can be used on a per-field level and on a per-filter level. Each field can contain multiple filters to perform different logic within the same field.
No more than 100 rows can be returned at a time. To return more, you should use skip
and limit
to paginate through results.
By default, all data in the database will be returned (up to the first 100 rows) in the default sort order, which is currently the time the row was created in descending order (most recent first).
content
Gets images and PPT assets for each row in a database.
You can get the database ID from the URL address bar while logged into Pitchly. When inside the account, the URL will follow the pattern:
https://v2.pitchly.net/t/<ORGANIZATION_ID>/d/<DATABASE_ID>/a/<APP_ID>
Variables:
Example result
Returns an array of rows. Each row has an _id
and an array oftemplates
for each row of data.
Advanced content queries
The sample query above may work fine for very simple queries, but the content endpoint allows us to pass many more options to query very specific information. Below is a list of optional variables the content endpoint additionally accepts, beside a secretKey
and databaseId
.
Variable | Type | Description |
filter | object | Narrows rows by specifying filter criteria |
sort | object | Sorts rows in ascending or descending order by field ID, in the order specified |
limit | number | The maximum number of rows to return (default = 100) |
skip | number | Skips the first N number of rows in the result set (useful for pagination) |
in | array | Limit resulting rows to the row IDs specified in this array |
search | string | Specifies a global search string where , is interpreted as and and | is interpreted as an or |
templatePaths | array of string | Specifies one or more templatePaths as returned by the database or databases endpoints. The returned rows will exactly match only these paths. Omitting this variable or supplying an empty array will return each row with all available templates. |
modifiedSince | string | Filters rows to only those created or updated since the date specified. Must be in the following format: |
Examples
Example 1 (simple)
Get rows where ID equals "order-2883"
Example 2 (relational)
Since different field types accept different filter parameters, here is a list of all the possible filter parameters for each field type. They can be used within the filters
array.
Conjunctions can be used to perform AND or OR operations at each step of a filter. Different logical conjunctions can be used on a per-field level and on a per-filter level. Each field can contain multiple filters to perform different logic within the same field.
No more than 100 rows can be returned at a time. To return more, you should use skip
and limit
to paginate through results.
By default, all data in the database will be returned (up to the first 100 rows) in the default sort order, which is currently the time the row was created in descending order (m
dataCount
Gets the total number of rows in a database, optionally filtered.
The optional filter and in parameters function the same as they do with the data endpoint.
Example result
Returns the number of rows in the database, or if filter
or in
are specified, the number of rows in the result, not subject to a limit.
Reference
Field properties
When getting information about the fields in a database using either the database or databases endpoints, the following properties will be returned for each field. A description of each property can be found below.
Field property | Return type | Description |
_id | string | The ID of the field |
name | string | The name of the field |
type | string | The data type of the field. Can be one of these types. |
primary | boolean | null | True if this field is the primary field in the database |
required | boolean | null | True if this field is required |
restrict | array | null | If field type is enum or enumTags, an array of all possible values |
database | string | null | If field type is ref or refMultiple, the ID of the database this field refers to |
Data types
Each field in a database can be one of the following types. Note that the programmatic name is different than the user-facing name for each type. The programmatic name is used throughout Pitchly's APIs, while the user-facing name is what the user sees through Pitchly's interface. Examples are representative of the value
object returned for each field in each row when getting data via the data endpoint.
Field type | User-facing name | Description & example |
string | Single-line text | Short single-line text
|
textBlock | Multi-line text | Long multi-line text
|
number | Number | Number w/ possible decimal
|
boolean | Yes/No | Binary true/false value
|
date | Date | Date in ISO 8601 Extended format (with zeroed UTC time)
|
currency | Currency | Currency amount & 3-char currency code (see list)
|
attachment | Attachment | File attachment of any type (size given in bytes)
|
enum | Dropdown | A single value selected from a dropdown of predefined values
|
enumTags | Dropdown multiple | Multiple values selected from a dropdown of predefined values
|
ref | Reference | Refers to a row from another database, by row ID
|
refMultiple | Reference multiple | Refers to multiple rows from another database, by row ID
|
Note on reference fields
The row IDs that are saved in reference fields refer to Pitchly's internal and unchangeable row ID for every row. This ID is globally unique to Pitchly, automatically generated, and is not readily exposed to users or defined by users of Pitchly.
Remember that these row IDs are present in the database being referenced by the ref or refMultiple field containing this value, specified by the database property of the ref field.
_label
is a convenient display-friendly version of each row being referenced based on the value of the primary field in the referenced row, returned as a string. If no primary field is set in the referenced database, _label
will become the row ID itself.
Note on empty values
Empty values can be represented one of two ways:
{ fieldId: "...", value: null }
{ fieldId: "...", value: { val: null } }
The first is when the value is considered "not set," which implies the value was empty when inserted into Pitchly and has never been changed. The second is when the value is "intentionally empty," which means it was set to empty intentionally. Once a value is made "intentionally empty," it cannot become "not set" again.
Note that in the second scenario, val
will always be null
regardless of the data type. If no values are selected in a Dropdown Multiple, for example, null
will be returned instead of an empty array. Empty strings will also be automatically converted to null
. This way, it is not necessary to know the data type of every field to check whether a value is empty.
Every field type can also potentially be empty, including boolean
fields. Required fields may also contain empty values under certain circumstances.
Filter parameters
Depending on the data type of a field, different filter options are available. At a filter's core is an object usually consisting of a by
property, and usually a value
or a slight varation thereof. Below is a list of possible filters for each data type.
string / textBlock
{ by: "is", value: "foo" }
{ by: "is-not", value: "foo" }
{ by: "starts-with", value: "foo" }
{ by: "ends-with", value: "foo" }
{ by: "contains", value: "foo" }
{ by: "does-not-contain", value: "foo" }
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
Currently, starts-with
, ends-with
, contains
, and does-not-contain
are case insensitive, while is
and is-not
are case sensitive.
number
{ by: "is", value: 5 }
{ by: "is-not", value: 5 }
{ by: "is-more-than", value: 5 }
{ by: "is-less-than", value: 5 }
{ by: "is-between", value: { val1: 5, val2: 10 } }
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
boolean
{ by: "is-true" }
{ by: "is-false" }
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
date
{ by: "on", value: "2020-01-23T00:00:00.000Z" }
{ by: "after", value: "2020-01-23T00:00:00.000Z" }
{ by: "before", value: "2020-01-23T00:00:00.000Z" }
{ by: "between", value: { val1: "2020-01-23T00:00:00.000Z", val2: "2020-02-23T00:00:00.000Z" } }
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
currency
{ by: "is", value: 5, currency: "USD" }
{ by: "is-not", value: 5, currency: "USD" }
{ by: "is-more-than", value: 5, currency: "USD" }
{ by: "is-less-than", value: 5, currency: "USD" }
{ by: "is-between", value: { val1: 5, val2: 10 }, currency: "USD" }
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
See all currency types
attachment
{ by: "has-any-value" }
{ by: "is-empty" }
{ by: "is-not-set" }
enum / enumTags
{ values: ["Houston", "Atlanta"], otherValues: ["is-empty", "is-not-set"] }
The above example will return results where Location contains either Houston, Atlanta, the field is empty, or it's not set.
Because Pitchly allows you to filter data relationally across tables, there is no need to filter directly against a ref or refMultiple field. That's why you won't find those here.
Last updated