Reseller API

From Ace Stream Wiki
(Redirected from Reseller API/en)
Jump to: navigation, search

Common description of API

This API allows you to work with user keys in Ace Stream system. API provides methods to create user keys and activate different options for the keys.

Requests format

API requests are sent via HTTP-GET method to the following addresses:

  • test mode: https://api-sandbox.acestream.net/reseller
  • work mode: https://api.acestream.net/reseller

Responses for these requests comes in json format.

If during query processing an error was occurred, the following kind of response will be sent:

{"error":"error descrtiption"}

Responses to successfully processed requests depend on a method being called

Required common parameters for all requests

  • method - called API method
  • api_key - API client key
  • api_version - supported API version (current version: 1.0)
  • app - market ID
  • sign - request's digital signature

Algorithm for generating a digital signature

  • array of strings like "parameter_name=parameter_value" is created
  • the resulting array is sorted
  • elements of the sorted array are combined in a string with a separator "#"
  • private key of API client is added to the resulting string
  • signature is sha1-hash of the resulting string (in hexadecimal representation, 40 characters, lowercase)

PHP code:

function makeSignature(array $params, $apiSecret)
{
    $checkParams = array();
    foreach($params as $k => $v) {
        $checkParams[] = $k . '=' . $v;
    }
    sort($checkParams);
    
    $payload = join('#', $checkParams);
    $sign = sha1($payload . $apiSecret);
    
    return $sign;
}

API methods

getServiceCost

Get the cost of a service

parameters:

  • service (string) - service ID
  • period (string) - period ID

fields in response:

  • cost (decimal) - the cost of the service for a specified period in EUR

request example:

https://api.acestream.net/reseller?method=getServiceCost ↵
  &api_version=1.0 ↵
  &api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
  &app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
  &service=noAds ↵
  &period=m1 ↵
  &sign=45c84ceffd3ec443586e8f4666b28abde8400768

response:

{"cost":1}

activateService

Activate service for user

As a result of successful activation, funds will be charged from reseller's balance.

parameters:

  • user_key (string) - user key
  • service (string) - service ID
  • period (string) - period ID

fields in response:

  • validFrom (unix timestamp) - from what time service is active
  • validTo (unix timestamp) - till what time service will be active

request example:

https://api.acestream.net/reseller?method=activateService ↵
  &api_version=1.0 ↵
  &api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
  &app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
  &user_key=a455865e5800fd7efab75f2b4852fc2497f9fc39 ↵
  &service=noAds ↵
  &period=m1 ↵
  &sign=c4df772a4a41ad7bbb4d7d07e46cad5e3622c59e

response (successful activation):

{"validFrom":1376048972,"validTo":1378640972}

response (there are not enough funds on resellers balance to activate the service):

{"error":"not enough credits"}

getUserKeyInfo

Get information about user key

parameters:

  • user_key (string) - user key

fields in response:

  • services (array) - array of services, bound to this user key. Each service ia described with the following fields:
    • id (string) - service ID
    • validFrom (unix timestamp) - from what time service is active
    • validTo (unix timestamp) - till what time service will be active
    • enabled (boolean) - is service active at this moment

request example:

https://api.acestream.net/reseller?method=getUserKeyInfo ↵
  &api_version=1.0 ↵
  &api_key=be6f66e0848528139583b567fb222215444fc8ac ↵
  &app=9_50gh753t6uscog88800kcksw04s0o0wccscco8kgsogwkocwgw ↵
  &user_key=8fb311be3836b04f61817dbf8a23c05739ebb13e ↵
  &sign=5e0fc46d908e5f224ce9fce9f6a83dd6b3502cc0

response (no services):

{"services":[]}

response (there are services):

{"services": [
     {"id": "noAds", "validFrom": 1374673235, "validTo": 1445089235, "enabled": true},
     {"id": "premium", "validFrom": 1374858187, "validTo": 1448301787, "enabled": true}
 ]}


createUserKey

Create a new user key

fields in response:

  • userKey (string) - created user key
  • extension (string) - content of extension file which is used for the following loading to the engine

request example:

https://api.acestream.net/reseller?method=createUserKey ↵
  &api_key=cd3119af58cfa8833ba105a4fd4eb791395b921c ↵
  &api_version=1.0 ↵
  &app=3_250o55jdisu88skggogg4g4w4wc8wgskss4gkgkkk40k0gcsw8 ↵
  &sign=99982a11708ef4a80e12f1ca845d314340db8869

response:

{
 "userKey": "c7456d962209ce22a8edd0c788940a15792bc575",
 "extension": "F5T6L+X\/TnhqoXP\/Tyzlad51LoGI3InF676iap ↵
n6vuJUOLbFJNGfYQcakQMXAhSTrlc7XlmUydoGcnCXhw5qefoinHZHIL ↵
VW51Pd5I0\/0YbKsmn\/Y78F1JhG1ckBExCtQTf\/NgLj+8TeTyPOfQS ↵
lRub3k4G\/m0+Iqyq4hshKnmTIBlkDcytWZ5DyQFLetllUUz9rLFjvR8 ↵
mF0qy3GCYtAw=="
}

Service ID

  • noAds - service "No ADs" (disable Ace Stream ads)
  • premium - service "Premium Streams" (access to premium content)
  • premium1device - premium for one device
  • proxyServer - "Proxy Server" option (it allows using Ace Stream by third-party software products)

Period ID

  • m1 - 30 days
  • y1 - 365 days