Print

Getting Started

To start using Developer API, you'll have to follow this steps:

  1. Create a Client. Each Client contains information used by Cafebazaar to authenticate an API user. To create a Client, go to your developer panel, click on the Developer API on the side menu to go to Developer API page. In this page click on the New Client button.
  2. In the opened modal, enter your desired value for Redirect URI. This address specifies where should Cafebazaar send the response to your request for Authentication Code in the next steps. You can set this address to somewhere in your server so that cafebazaar redirect you to it or you can set it to any address and do the following steps manually.
  3. Go to the following address: https://pardakht.cafebazaar.ir/devapi/v2/auth/authorize/?response_type=code&access_type=offline&redirect_uri=<REDIRECT_URI>&client_id=<CLIENT_ID> Note that you should replace <REDIRECT_URI> and <CLIENT_ID> with values from the Client you've created in the previous steps.
  4. If your information are correct, you'll see a page demanding your authorization. Click on Authorize.
  5. Your browser will redirect you to the address you've entered as Redirect URI. The Authentication Code is sent with this request as a GET query field with the name "code", which looks similiar to affAKBEs80Yz1AjHXtoKHZnWj1UItfnKwp1b5FRg.
  6. By sending a POST requsest to:https://pardakht.cafebazaar.ir/devapi/v2/auth/token/With these fields:grant_type=authorization_code code=<the code from the previous step> client_id=<the client ID token from your defined Client in previous steps> client_secret=<the client secret from your defined Client> redirect_uri=<the redirect URI from your defined Client> You will recieve access_token and refresh_token.
    A successful response will be JSON format and looks similiar to: { "access_token": "GWObRK06KHLr8pCQzDXJ9hcDdSC3eV", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "yBC4br1l6OCNWnahJvreOchIZ9B6ze", "scope": "androidpublisher" }In case of an error, you'll recieve a response with 40X status code, with a body of JSON object containing an error field which specifies the error.
  7. Now that you have recieved your access_token, you can use the API by sending these kind of requests:https://pardakht.cafebazaar.ir/devapi/v2/api/<your desired function>?access_token=<access_token you've recieved>You can also put access_token in Authorization header of your request instead.
    In case of an error, you'll recieve a response with 40X status code, with a body of JSON object containing an error field which specifies the error and an error_description field explaining the cause of error.
  8. Each access_token is only valid for a short time. After your access_token expired, you can get a new one from Cafebazaar using your refresh_token. To do so, send a POST request to:https://pardakht.cafebazaar.ir/devapi/v2/auth/token/With these fields:grant_type=refresh_token client_id=<the client ID token from your defined Client> client_secret=<the client secrey from your defined Client> refresh_token=<the refresh token from the previous steps> A successful response will be JSON format and looks similiar to:{ "access_token": "uX5qC82EGWjkjjeyvTzTufHOM9HZfM", "token_type": "Bearer", "expires_in": 3600, "scope": "androidpublisher" }In case of an error, you'll recieve a response with 40X status code, with a body of JSON object containing an error field which specifies the error.
    Using this, your server can access Developer API continuously.
Was this content helpful?
Write your comment here...

If you have any comment on this content or any idea to make it better, use this form to send us your comment.

Publish Date: ۱۴۰۰-۰۳-۲۹ ۰۸:۱۹

Latest Update: ۱۴۰۰-۰۴-۱۴ ۰۶:۱۲