Printavo API v2.0

These GraphQL API docs are used to access information in your Printavo account. Printavo is the simplest way for screen-printing, embroidering and promotional product shops to manage their business.

Rate Limiting

For API requests, we allow a maximum of 10 requests for every 5 seconds per user email or IP address.

Get Started

Requests to Printavo API v2.0 are made to the following endpoint and you will need the authentication headers below:

API v2.0 Endpoint:

www.printavo.com/api/v2

Authentication Headers

const headers = {
  'Content-Type': 'application/json',
  'email': '{{youremail@email.com}}',
  'token': '{{API token from My Account page}}'
};

New to GraphQL?

GraphQL is a departure from traditional API paradigms designed around the idea of limiting excess in requests and responses, and providing users and developers the tools to tailor their actions to exactly what they need. The core concept of GraphQL can be described as "ask for what you want and that's exactly what you'll get".

The Basics

Data models in GraphQL are called "types" and information about them is stored in their "fields". A request to a GraphQL server will define exactly the fields that it wants to query or mutate about an object or set of objects, and will specify what the response should include. More on that can be found in the query and mutation documentation.

Collections and Pagination

A set of data objects (such as Customers or Invoices) is returned in a connection, and each individual object inside the connection object is called a "node".

By default, the Printavo API paginates connections into pages of twenty-five nodes. In addition, each connection reports its totalNodes value to notify the requester of how many nodes are in the connection overall. Additionally, GraphQL supports slicing, which allows a user to specify where in the list of nodes they would like to begin their search as well as how many nodes they'd like to request. For example, here is a request to retrieve 5 Tasks at a time:

query {
  tasks {
    nodes(first: 5) {
      id
    }
  }
}

Aliasing

GraphQL also supports aliasing for queries, mutations, and individual fields, allowing a user to customize the labels in the returned data. For one such example, take a look at the following query:

query {
  taskAlias: tasks {
    nodes {
      nameAlias: name
    }
  }
}

The query defines an alias, taskAlias, for the tasks query and requests that each node in the returned connection contains the name field aliased as nameAlias. The response would correspondingly look like this:

{
  "data": {
    "taskAlias": {
      "nodes": [
        {
          "nameAlias": "Prepare the screens"
        },
        ...
      ]
    }
  }
}

Conventions: the use of !

In GraphQL, the use of the exclamation point carries two meanings, depending on context. In the context of an argument, it represents a required argument, such as in the query provided below:

query {
  task(id: ID!) {
	...
  }
}

In the task query, the use of ! indicates that an ID value is required, otherwise the query can't resolve.

In the context of a returned field, it represents a non-nullable value. For fields that return connections, the ! signifies that GraphQL will always return a connection even if that connection is empty. Several examples of this can be found on the InvoiceType, but let's look at its fees field and break it down:

fees (FeeConnection!)

If you were to query for an Invoice which had no fees attached to it, what that ! is signifying is that you'd still receive a connection when you queried the fees field, but that connection would contain no nodes. In effect, this ! denotes a promise from the GraphQL server to the user, that they can depend on something being returned and that the server won't unexpectedly return a null value when that field is requested.

Continued Reading

The above are just a few select conventions and principles that form the core of what GraphQL is all about. In order to learn more, check out GraphQL's official documentation!