Difference between revisions of "Reseller API"
(→Обязательные общие параметры для всех запросов) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==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: <tt><nowiki>https://api-sandbox.acestream.net/reseller</nowiki></tt> |
− | * | + | * work mode: <tt><nowiki>https://api.acestream.net/reseller</nowiki></tt> |
− | + | Responses for these requests comes in json format. | |
− | + | If during query processing an error was occurred, the following kind of response will be sent: | |
<tt><nowiki>{"error":"error descrtiption"}</nowiki></tt> | <tt><nowiki>{"error":"error descrtiption"}</nowiki></tt> | ||
− | + | Responses to successfully processed requests depend on a method being called | |
− | === | + | ===Required common parameters for all requests=== |
− | * '''method''' - | + | * '''method''' - called API method |
− | * '''api_key''' - | + | * '''api_key''' - API client key |
− | * '''api_version''' - | + | * '''api_version''' - supported API version (current version: 1.0) |
− | * '''app''' - | + | * '''app''' - market ID |
− | * '''sign''' - | + | * '''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: | |
<tt><nowiki>function makeSignature(array $params, $apiSecret) | <tt><nowiki>function makeSignature(array $params, $apiSecret) | ||
{ | { | ||
Line 43: | Line 43: | ||
}</nowiki></tt> | }</nowiki></tt> | ||
− | == | + | ==API methods== |
===getServiceCost=== | ===getServiceCost=== | ||
− | + | Get the cost of a service | |
− | + | parameters: | |
− | * '''service''' (''string'') - | + | * '''service''' (''string'') - service ID |
− | * '''period''' (''string'') - | + | * '''period''' (''string'') - period ID |
− | + | fields in response: | |
− | * '''cost''' (''decimal'') - | + | * '''cost''' (''decimal'') - the cost of the service for a specified period in EUR |
− | + | request example: | |
<nowiki>https://api.acestream.net/reseller?method=getServiceCost ↵ | <nowiki>https://api.acestream.net/reseller?method=getServiceCost ↵ | ||
&api_version=1.0 ↵ | &api_version=1.0 ↵ | ||
Line 64: | Line 64: | ||
&sign=45c84ceffd3ec443586e8f4666b28abde8400768</nowiki> | &sign=45c84ceffd3ec443586e8f4666b28abde8400768</nowiki> | ||
− | + | response: | |
<nowiki>{"cost":1}</nowiki> | <nowiki>{"cost":1}</nowiki> | ||
===activateService=== | ===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''' (''string'') - user key |
− | * '''service''' (''string'') - | + | * '''service''' (''string'') - service ID |
− | * '''period''' (''string'') - | + | * '''period''' (''string'') - period ID |
− | + | fields in response: | |
− | * '''validFrom''' (''unix timestamp'') - | + | * '''validFrom''' (''unix timestamp'') - from what time service is active |
− | * '''validTo''' (''unix timestamp'') - | + | * '''validTo''' (''unix timestamp'') - till what time service will be active |
− | + | request example: | |
<nowiki>https://api.acestream.net/reseller?method=activateService ↵ | <nowiki>https://api.acestream.net/reseller?method=activateService ↵ | ||
&api_version=1.0 ↵ | &api_version=1.0 ↵ | ||
Line 91: | Line 91: | ||
&sign=c4df772a4a41ad7bbb4d7d07e46cad5e3622c59e</nowiki> | &sign=c4df772a4a41ad7bbb4d7d07e46cad5e3622c59e</nowiki> | ||
− | + | response (successful activation): | |
<nowiki>{"validFrom":1376048972,"validTo":1378640972}</nowiki> | <nowiki>{"validFrom":1376048972,"validTo":1378640972}</nowiki> | ||
− | + | response (there are not enough funds on resellers balance to activate the service): | |
<nowiki>{"error":"not enough credits"}</nowiki> | <nowiki>{"error":"not enough credits"}</nowiki> | ||
===getUserKeyInfo=== | ===getUserKeyInfo=== | ||
− | + | Get information about user key | |
− | + | parameters: | |
− | * '''user_key''' (''string'') - | + | * '''user_key''' (''string'') - user key |
− | + | fields in response: | |
− | * '''services''' (''array'') - | + | * '''services''' (''array'') - array of services, bound to this user key. Each service ia described with the following fields: |
− | ** '''id''' (''string'') - | + | ** '''id''' (''string'') - service ID |
− | ** '''validFrom''' (''unix timestamp'') - | + | ** '''validFrom''' (''unix timestamp'') - from what time service is active |
− | ** '''validTo''' (''unix timestamp'') - | + | ** '''validTo''' (''unix timestamp'') - till what time service will be active |
− | ** '''enabled''' (''boolean'') - | + | ** '''enabled''' (''boolean'') - is service active at this moment |
− | + | request example: | |
<nowiki>https://api.acestream.net/reseller?method=getUserKeyInfo ↵ | <nowiki>https://api.acestream.net/reseller?method=getUserKeyInfo ↵ | ||
&api_version=1.0 ↵ | &api_version=1.0 ↵ | ||
Line 118: | Line 118: | ||
&sign=5e0fc46d908e5f224ce9fce9f6a83dd6b3502cc0</nowiki> | &sign=5e0fc46d908e5f224ce9fce9f6a83dd6b3502cc0</nowiki> | ||
− | + | response (no services): | |
<tt>{"services":[]}</tt> | <tt>{"services":[]}</tt> | ||
− | + | response (there are services): | |
<nowiki>{"services": [ | <nowiki>{"services": [ | ||
{"id": "noAds", "validFrom": 1374673235, "validTo": 1445089235, "enabled": true}, | {"id": "noAds", "validFrom": 1374673235, "validTo": 1445089235, "enabled": true}, | ||
Line 129: | Line 129: | ||
===createUserKey=== | ===createUserKey=== | ||
− | + | Create a new user key | |
− | + | fields in response: | |
− | * '''userKey''' (''string'') - | + | * '''userKey''' (''string'') - created user key |
− | * '''extension''' (''string'') - | + | * '''extension''' (''string'') - content of extension file which is used for the following loading to the engine |
− | + | request example: | |
<nowiki>https://api.acestream.net/reseller?method=createUserKey ↵ | <nowiki>https://api.acestream.net/reseller?method=createUserKey ↵ | ||
Line 143: | Line 143: | ||
&sign=99982a11708ef4a80e12f1ca845d314340db8869</nowiki> | &sign=99982a11708ef4a80e12f1ca845d314340db8869</nowiki> | ||
− | + | response: | |
<tt>{ | <tt>{ | ||
"userKey": "c7456d962209ce22a8edd0c788940a15792bc575", | "userKey": "c7456d962209ce22a8edd0c788940a15792bc575", | ||
Line 153: | Line 153: | ||
}</tt> | }</tt> | ||
− | == | + | ==Service ID== |
− | * '''noAds''' - | + | * '''noAds''' - service "No ADs" (disable Ace Stream ads) |
− | * '''premium''' - | + | * '''premium''' - service "Premium Streams" (access to premium content) |
− | * '''premium1device''' - | + | * '''premium1device''' - premium for one device |
+ | * '''proxyServer''' - "Proxy Server" option (it allows using Ace Stream by third-party software products) | ||
− | == | + | ==Period ID== |
− | * '''m1''' - 30 | + | * '''m1''' - 30 days |
− | * '''y1''' - 365 | + | * '''y1''' - 365 days |
Latest revision as of 15:07, 6 September 2017
Contents
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