ClickBank API
Please note, the ClickBank API is for use by those with significant development experience.
The ClickBank API makes it possible for a wide range of computer programs to securely access ClickBank account information on behalf of ClickBank account owners. Some of the functions available to users of the API include the ability to:
- Request a refund for a customer’s purchase
- Request a cancelation for a customer’s subscription
- Retrieve a list of transactions in a ClickBank account for a given timeframe
The possibilities for programs that make use of the ClickBank API are many and include: a dashboard that shows ClickBank data in addition to data from accounts with other online services, a subscription management tool, and an analytics package that shows data about trends in sales for a particular ClickBank account. All of these applications and more are possible with the new ClickBank API. Plus they could be sold in the ClickBank Marketplace as well!
The ClickBank Service API is built on a REST architecture and provides a reliable and secure http based mechanism to retrieve data.
REST
REST is an architecture style pioneered by Roy Fielding, who was one of the principal authors of the HTTP protocol in his dissertation- “Architectural Styles and the Design of Network-based Software Architectures.” A brief introduction to REST can be found in the Wikipedia article Representational State Transfer.
Versioning
The current version of ClickBank’s Service API is: 1.2.
The version information is part of the URL to access the services. This provides the following benefits:
- Clear information about what version of the API is being used
- An easy to understand upgrade path when new API versions are announced
The ClickBank Service API is guaranteed to be backwards compatible up to three releases. For example, when version 4.0 of the API is released, version 1.2 will still function.
Infrastructure
ClickBank’s REST API is based on JSR-311 – The Java API for RESTful Web Services. This is an implementation detail for the ClickBank Service API. The services themselves are HTTP based and implementation agnostic; therefore, any web client (.NET, PHP, Java, Python, Ruby, etc) can utilize the services.
While ClickBank does not endorse any REST tools for development, we do find RestClient to be very helpful while developing and testing RESTful web services.
Request Header
ClickBank’s Service API Header consists of security, output, and page parameters. The ClickBank Service API only accepts query parameters; requests built on form based (post) parameters are ignored.
The HTTP spec indicates that a URL cannot be more than 2k in length. API developers should ensure that the length of the API rest url’s are less than 2000 characters.
Certification
With some programming languages the ClickBank’s Service API will require your system to possess a certificate for the following domain:
*.clickbank.com
To acquire the certificate, simply go to the following URL, double click the authentication lock in the lower right-hand corner of your browser, and save the certificate to your system
https://api.clickbank.com/rest/1.2/orders
Security
ClickBank’s Service API methods are secure and will return a 403 [Forbidden] status code if accessed without the right credentials. Secure access to the API requires an Authorization header parameter containing the following keys:
- Developer key – The Developer key grants the user the “ROLE_HAS_DEVELOPER_KEY” role.
- Clerk user key – The Clerk key grants the user either the “ROLE_API_ORDER_READ” or “ROLE_API_ORDER_WRITE” role.
Conceptually, a developer key is a token which is generally used to allow access to the API’s; while a clerk user API key is generally associated with a particular user. When creating the header parameter with both roles, each value must be separated by a colon.
Example:
| Authorization | DEV-F7F8023A486E9A9602FFDA2765E1925:API-9870acb8d96f8bd18c2eb70725b01fe4b98ece58 |
Some of the ClickBank Service APIs (most notably the sandbox) do not require both keys. The Supported API documentation lists the required roles to access a particular service. If only the developer key is required, a colon in the header parameter is not necessary.
Example:
| Authorization | DEV-F7F8023A486E9A9602FFDA2765E1925 |
To acquire Developer and Clerk keys, simply login to your ClickBank account and go to the Account Settings tab. Then, click “edit” in the Developer and Clerk API Key areas.
Each key must be approved, present, and active for successful authentication to occur.
Output
ClickBank’s Service API supports the following output formats:
- XML
- JSON
- CSV (only work with the Orders API)
Request the output format by including an Accept parameter in the http header. If an unsupported format is requested the server will provide a 500 [Internal Server Error] status code.
Example:
| Accept | application/xml |
Pagination
The API will never return more than a 100 rows for any service call. For requests that contain more than 100 rows of data, the API will return the first 100 rows with a status code of 206 [Partial Content]. To retrieve the additional pages, the developer must include a Page header parameter indicating which page of the result is desired.
Example:
| Page | 3 |
Once the last page is accessed, the service will return a 200 [OK] instead of a 206 [Partial Content].
Supported APIs
For version 1.2, the following API’s will be supported:
- Orders API: https://api.clickbank.com/rest/1.2/orders
- The Orders API allows you to get order information by receipt or date/time parameters.
- Tickets API: https://api.clickbank.com/rest/1.2/tickets
- The Ticket API allows you to update an order’s status to returned or canceled thru the creation of a transaction ticket. Additionally, you may search for existing tickets by user.
- Sandbox API: https://sandbox.clickbank.com/rest/1.2/sandbox
- The Sandbox API provides an environment to create test accounts, developer keys, and orders. Once established, it can be used to test the tickets and order API’s.
Each ClickBank API is self-describing. For service description details, simply access the API URL.
Additional Tools
Debugging
The ClickBank API provides a debug web service [/rest/1.2/debug]. The service prints out the request context information [including the security context information], which can be very useful when correcting REST API issues.
Code Samples
The following code samples demonstrate how a developer might utilize the APIs:
A) C# – https://sandbox.clickbank.com/api_12_examples/api_example.csharp
B) Java – https://sandbox.clickbank.com/api_12_examples/api_example.java
C) PHP – https://sandbox.clickbank.com/api_12_examples/api_example.php
D) Python – https://sandbox.clickbank.com/api_12_examples/api_example.py
E) Ruby – https://sandbox.clickbank.com/api_12_examples/api_example.rb


