|
and Register
Home
Contact Us

API Quick Start

Signing Up

Self-service registration is now open. You can register for free using your email address and then log in. After successfully logging in, you will automatically receive a self-registration package. You can debug interfaces and browse API documentation in the "My API" menu.

API Credentials

Once you get the API package usage, log in the system and go to the Personal Center Page. Your API credentials are a Client ID and a Client Secret.

The packages and package usages are on the same page. You can find how many API calls can be made and have been made.

Bearer Authentication

1. Generate Authorization based on Base64 encoding rules through Client ID and Client Secret;
2. Carry Authorization as the request header to request a token;
3. Note: The token is valid for 30 minutes.

 

Client ID is b4562e4188asd4cb486a19c6971515c66(example).
Client Secret is N1eOgd8sOk4z1vaWQfB18P4AbSk70lGs(example).
You can form the POST command as below to get the Bearer.
For example:
  • Curl
  • NodeJS
  • Python
  • Java
curl -X "POST" "https://connect.patsnap.com/oauth/token" \
    -H "Content-Type: application/x-www-form-urlencoded " \
    -u b4562e4188asd4cb486a19c6971515c66:N1eOgd8sOk4z1vaWQfB18P4AbSk70lGs \
    -d "grant_type=client_credentials"
const request = require('request');
request.post(
    {
        // eslint-disable-next-line no-template-curly-in-string
        url: 'https://b4562e4188asd4cb486a19c6971515c66:N1eOgd8sOk4z1vaWQfB18P4AbSk70lGs@connect.patsnap.com/oauth/token',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        form: 'grant_type=client_credentials',
    },
    (err, res, body) => {
        if (!err) {
            console.log(body);
        } else {
            console.log('error authenticate', err);
        }
    }
);
import requests
url = "https://b4562e4188asd4cb486a19c6971515c66:N1eOgd8sOk4z1vaWQfB18P4AbSk70lGs@connect.patsnap.com/oauth/token"
payload = "grant_type=client_credentials"
headers = {
    "content-type": "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
public static void main(String[] args) {
    String host = "https://b4562e4188asd4cb486a19c6971515c66:N1eOgd8sOk4z1vaWQfB18P4AbSk70lGs@connect.patsnap.com";
    String path = "/oauth/token";
    Map headers = new HashMap();
    headers.put("Content-Type", "application/x-www-form-urlencoded");

    Map requestbody = new HashMap();
    requestbody.put("grant_type", "client_credentials");

    try {
        /**
        * Important Tips:
        * Please Download HttpUtils From
        * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
        *
        * Please refer to the corresponding dependence:
        * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
        */
        HttpResponse response = HttpUtils.doPost(host, path, null, headers, null, requestbody);
        System.out.println(EntityUtils.toString(response.getEntity()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Copy

The content returned is as follows.

  • json
{
    "token": "token_example",
    "token_type": "BearerToken",
    "expires_in": 1799,
    "status": "approved",
    "issued_at":"1692347672874"
}
Copy

Business APIs

After you get the Bearer, you can use it to access the business APIs according to your package.

For Example if you want to get the patent information by patent number. You can GET With apikey, and Header Authorization, the apikey is the client id, the Authorization is Bearer [Bearer]

Here is how the command organized. (Please note the space between "Bearer" and "token_example")

Response Code

error_codedescription
67200000
Server Internal Error!
67200001
API call exceeds the total limit set by the platform!
67200002
The current call rate is too fast, exceeding the current configuration limit QPS!
67200003
The key and secret parameters for applying for the token are incorrect or the client has been disabled!
67200004
The requested api does not have permission. Please contact our support personnel!
67200005
Insufficient account balance/number of calls!
67200006
The client has exceeded the activation validity period!
67200007
The current call exceeds the configured usage limit of the day!
67200008
Please check if the required apikey in the query parameter has been transmitted!
67200009
The apikey does not match the passed bearerToken. Please check if a valid token is being used!
67200012
The request is illegal!
67200100
The current server status is busy, request response timeout!
67200101
The API requested currently does not exist. Please check the request path!
68300004
Invalid parameter!
68300005
Search api failure!
68300006
Analytic basic access error!
68300007
Bad request!
68300008
Service error, please try again later!
68300010
The file does not comply with upload specifications!