About the FastSpring API
This article provides information about the FastSpring API.
Table of Contents
What is the FastSpring API?
The FastSpring API is a back-end service you can use to communicate with your FastSpring Store programatically, e.g., as an alternative to using the FastSpring App. The API is an advanced feature that requires some basic understanding of HTTP communication methods; GET, POST, and DELETE are the primary methods used to communicate with the API.
The structure of the JSON data sent and received using the API is very similar to webhooks. However, with webhooks, FastSpring proactively sends you data about subscribed events in near-real-time, as the events happen. You create and arrange hosting for a script that parses these posts as they come in. By contrast, using the FastSpring API, you initiate all communication with your FastSpring Store, on demand. You can request data from your Store using the GET method, and you can send data to your Store (for example, creating a new product record) using the POST method.
Using webhooks does not preclude the use of the API, nor does using the API prevent you from subscribing to and receiving webhook events. Indeed, one of the API endpoints (/events) exists specifically to help you manage your webhook events.
Because the FastSpring API is a back-end service and does not interact with customers' Web browsers, it may be more secure compared to client-side methods of communicating with FastSpring, such as the Store Builder Library. (However, the Store Builder Library does offer enhanced security measures such as the secure payload, as well.)
Here are just a few practical examples of ways you might take advantage of the FastSpring API:
|Creating a batch of numerous product records without using the FastSpring App||/products|
|Looking up a customer's account details in real-time, on demand||/accounts|
|Validating a customer's access to your service based on order details||/orders|
|Creating a custom order session for a specific customer that may override standard product pricing and pre-fill customer data||/sessions|
|Retrieving product details such the description, price, or image from your FastSpring Store in real-time to populate your own web pages||/products|
Accessing the API
Address of the FastSpring API
API Credentials and Authentication
FastSpring API credentials consist of a single username and password for your entire Store. The username and password are used for "Basic Authentication" when making requests to the API.
To Obtain Your API Credentials
- Log on to the FastSpring App and navigate to Integrations > API Credentials. Initially, the only option on this page is the Create command.
- Click Create to generate your API Username and Password. The page automatically refreshes, and then your credentials are displayed.
- Make a note of the credentials and store them securely.
When preparing your database structure for storing values obtained from FastSpring via our JSON payloads, you might assume the following datatypes:
- All "string" columns are VARCHAR 255, accordingly trimmed
- Encoding is UTF-8
- For numeric values (such as price or discount values) 2dp precision is expected ("2.00")
Available API Endpoints
|/accounts||Work with customer accounts and FastSpring-generated account IDs||
|/coupons||Work with promotional coupons and their customer-facing codes Create a coupon||
|/events||Retrieve unprocessed webhook events and mark events processed||
|/orders||Work with order/transaction records||
|/products||Work with product records||
|/returns||Work with returns and refunds||
|/sessions||Create a pre-loaded cart session for a specific customer with a FastSpring-generated account IDs; you can load the session in a Popup Storefront or provide the customer with a link to the session via a Web Storefront||
|/subscriptions||Work with customers' recurring-billing subscription instances Get all subscription instances||
To maintain a responsive user experience, FastSpring may impose request rate limits on API calls originating from individual accounts. If you encounter the rate limit, the response to the API request is an HTTP 404 response code (though this may be improved soon).
If you need to make a large number of API requests in a very short time, such that you may encounter rate limits, consider using batch requests where possible. For example, when retrieving authenticated account management URLs, you can obtain URLs for multiple account IDs in a single request:
You can find more information about this example in our Knowledge Base article about the /accounts endpoint.