Developer API

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

Common description of API

This API allows application developers to work with user keys in Ace Stream system. API provides methods for creating user keys and activating 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/developer
  • work mode: https://api.acestream.net/developer

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)
  • product - public part of product key
  • 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/developer?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 developer'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/developer?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 developer's 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/developer?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

Effect of user key applies only to developer's product, specified in parameter product.

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/developer?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 - service "Premium Streams" for one device

Period ID

  • m1 - 30 days
  • y1 - 365 days