Skip to content

rest api

Davod Saraei edited this page Sep 6, 2020 · 24 revisions

Table Of contents

A reference guide to the Affili REST API.

The Affili API is based around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application (though you should never expose your secret API key in any public website’s client-side code). JSON is returned by all API responses, including errors. We keep our customers up to date on new changes on the Affili API through our changelog.

Version

The current version of the API is V1.0.

Authentication

Authentication with the Affili API is achieved by sending your ACCESS ID along in the header of every request:

authorization: Bearer "YOUR_ACCESS_ID"

You can find and manage your Access Id in your developer's section of your panel.

Base API URL

https://core.affili.ir/

Cookies

POST Set Cookie

/api/merchants/set-cookie

Sample request
curl --location --request POST 'https://core.affili.ir/api/merchants/set-cookie' \
--data-raw '{
    "referrer": "5f53a29fb867dd7df313d4e2"
}'

Conversions

GET Retrieve a Conversion

/api/merchants/conversions/{id}

Sample result
{
    "status": "ok",
    "tag": "findConversion",
    "data": {
        "id": "eroxr",
        "publisher": {
            "id": "0j18r",
            "name": "John Doe"
        },
        "status": 1,
        "type": 6,
        "wage": 40,
        "amount": 200,
        "created_at": "1399-01-17 12:46:38",
        "updated_at": "1399-02-10 19:30:50",
        "external_id": "1234",
        "commissions": [
            {
                "id": "eroxr",
                "name": "buy",
                "sub_amount": 200
            }
        ],
        "is_closed": 1,
        "checked_out": 1,
        "client": {
            "agents": [
                "Chrome"
            ],
            "ips": [
                "127.0.0.1"
            ]
        },
        "clicks": []
    },
    "api_version": "1.0.0"
}
Column Description
id Primary initial key
publisher User with publisher role where created conversion
type Type of conversion where can be 'buy', 'click', 'lead'
status Status of conversion
wage Amount of Affili's fee
amount Total order amount
external_id A unique id for this conversion
commissions An array of commissions where name is commission key and sub_amount is the amount of category order`
is_closed Is conversion editable or not
checked_out Is conversion checked out or not
client Client data
clicks Clicks data

Status can be the following variables pending: 0, approved: 1, rejected: 2, duplicated: 3


GET List all conversions

/api/merchants/conversions

URI Parameters
Parameter Type
status 0 or 1 0r 2 or 3
external_id string
is_closed 0 or 1
checked_out 0 or 1
min_commission_amount integer
max_commission_amount integer
min_created_at date-time
max_created_at date-time
min_updated_at date-time
max_updated_at date-time
min_amount integer
max_amount integer
min_wage integer
max_wage integer

Note: All of the date-times must be the Gregorian date.


POST Update a Conversion

/api/merchants/conversions/{id}

Arguments
argument Description
external_id optional A unique id for this conversion
amount optional Total amount of order
commissions required if amount set An array of commissions where name is commission key and sub_amount is the amount of category order`
type optional Type of conversion where can be 'buy', 'click', 'lead'
status optional Status of conversion

Status can be the following variables pending: 0, approved: 1, rejected: 2, duplicated: 3

Sample request
curl --location --request POST 'https://core.affili.ir/api/merchants/conversions/eroxr' \
--data-raw '{
    "external_id": "123",
    "amount": "2000",
    "commissions": [
        {
            "name": "buy",
            "sub_amount": "2000"
        }
    ],
    "type": "buy",
    "status": "1"
}'

POST Create a conversion

/api/merchants/conversions

Arguments
argument Description
external_id required if type='buy' A unique id for this conversion
amount required if type='buy' Total amount of order
token required A client's identifier. This corresponds to the value of the token in the set-cookie API
aff_id required An affiliate’s id. This corresponds to the value of aff_id= in their referral link
referrer required An affiliate’s referral code. This corresponds to the value of referrer= in their referral link
commissions required if type='buy' An array of commissions where name is commission key and sub_amount is the amount of category order`
type required Type of conversion where can be 'buy', 'click', 'lead'
name required if type='lead' The name of the CPL commission

Note: An external_id is a unique id for the conversion. It can be anything meaningful to you, like an order number, user id, email address, etc… After a conversion has taken place, you can find this id alongside the conversion on our platform. This makes it very easy to cross-reference data on our platform with your administration. This id has to be unique for every conversion.

Sample request
curl --location --request POST 'https://core.affili.ir/api/merchants/conversions' \
--data-raw '{
    "external_id": "12345",
    "amount": "10000",
    "token": "eyJpdiI6IjBtZGhoaE03SmRHMTDUyMzJhNjEc1OTEyZDE2M2NTA3OTE5M2I4In0",
    "aff_id": "affili12439651d0m",
    "referrer": "5f53a29fb867dd7df313d4e2",
    "commissions": [
        {
            "name": "buy",
            "sub_amount": "10000"
        }
    ],
    "type": "buy"
}'