Documentation Sweet Pricing API

Sweet Pricing API

The Sweet Pricing API is a RESTful HTTP API that allows you to manage your Sweet Pricing account, create pricing models, manage your in-app stores and more. In fact, anything that you can do from App Manager, you can also do using the API.

Most app publishers do not need to use Sweet Pricing API. You only need to use the API for complex integrations, where you require automation beyond that provided by our software.

Overview of Sweet Pricing API

The endpoints of Sweet Pricing API are available at the following URL:

https://api.sweetpricing.com/v1

In the above URL, 'v1' represents the minor version of the API. At the current time, there is only one version of the API available, but in the future this could be 'v1.1' or 'v2', for example. We follow semver semantics, so you should consider 'v1.1' to be fully backwards compatible with 'v1', but you should consider 'v2' to be incompatible with 'v1.1'.

So, for example, a request to the platforms resource would look something like this:

$ curl -XGET 'https://api.sweetpricing.com/v1/platforms'
{"platforms":[{"id":1,"created":"2016-04-29T14:45:16.000Z","creatorUserId":1,
"name":"Android"},{"id":2,"created":"2016-04-29T14:45:16.000Z",
"creatorUserId":1,"name":"iOS"}]}

In the above example, we have requested a collection. Notice that the response is not an array, but instead a wrapper object with a platforms property. In some collection endpoints, this object might also contain other properties, such as page number or result set size.

Authentication

For most Sweet Pricing API endpoints, you need to authenticate before you perform the request. If you do not authenticate correctly, the endpoint will send a HTTP/1.1 401 Unauthorized response.

To become authorized, you must POST /sessions with the credentials of the account you wish to use.

$ curl -XPOST 'https://api.sweetpricing.com/v1/sessions'
  --data "email=example%40example.com&password=123456"
{
  "created": "2016-08-09T16:10:06.000Z",
  "id": 60,
  "creatorUserId": 2,
  "token": "6633e96ca2d4ae7044234eb91eb571fe",
  "userId": 2,
  "clientId": 1
}

Then, to perform an authenticated request, you must pass token to the endpoint in the following way:

  • Header authentication: Pass a header named session-token with the token value; or
  • Query string authentication: Add a ?sessionToken=<token> argument to the query string.