summaryrefslogtreecommitdiff
path: root/build/html/_sources/makingrequests/makingrequests.rst.txt
blob: d628feca93dbed76a8149a75017484c5e394cfa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.. _makingrequests:

Making Requests
===============

Content Negotiation
---------------------------

Content Negotiation
Clients using the api should specify that they accept responses using the ``application/vnd.api+json`` format, for convenience we will also accept ``application/json`` since it is the default for many popular client libraries.

The Server will respond with a ``Content-Type`` header that mirrors the format requested by the Client.

Regions
---------------------------

The Vainglory Game Data Service currently supports the following regions:

*General Region Shards:* To find data regarding live servers, where all data is found, please use the following shards.

* **North America:** ``na``
* **Europe:** ``eu``
* **South America:** ``sa``
* **East Asia:** ``ea``
* **Southeast Asia (SEA):** ``sa``

*Tournament Region Shards:* To find data regarding professional eSport, which take place on the private client only, please use the following shards.

* **North America Tournaments:** ``tournament-na``
* **Europe Tournaments:** ``tournament-eu``
* **South America Tournaments:** ``tournament-sa``
* **East Asia Tournaments:** ``tournament-ea``
* **Southeast Asia Tournaments:** ``tournament-sg``

*Please note: Choosing a specific region is currently required*

**Javascript:**

.. code-block:: javascript

  To specify a region, use this code:

  "...gamelockerapp.com/shards/<region>/..."



GZIP
---------------------------

Clients can specify the header ``Accept-Encoding: gzip`` and the server will compress responses.
Responses will be returns with ``Content-Encoding: gzip``.

Given the size of matches, this can have significant performance benefits.

**Shell:**

.. code-block:: javascript


  To specify the header Accept-Encoding, use this code:

  -H "Accept-Encoding: gzip"


**Java:**

.. code-block:: java


  To specify the header Accept-Encoding, use this code:

  conn.setRequestProperty("Accept-Encoding","gzip");


**Python:**

.. code-block:: python


  To specify the header Accept-Encoding, use this code:

  header = {"Accept-Encoding":"gzip"}


**Go:**

.. code-block:: go


  To specify the header Accept-Encoding, use this code:

  req.Header.Set("Accept-Encoding", "gzip")



Pagination
---------------------------

Where applicable, the server allows requests to limit the number of results returned via pagination. To paginate the primary data, supply pagination information to the query portion of the request using the limit and offset parameters. To fetch items 2 through 10 you would specify a limit of 8 and an offset of 2:

If not specified, the server will default for matches to ``limit=5`` and ``offset=0``, and for players/samples to ``limit=50`` and ``offset=0``

 *Important - Currently the server will not allow responses with over 50 primary data objects*



Search Time
---------------------------


**Defaults:**

* Data retention period: 120 days.
* The max search time span between createdAt-start and createdAt-end: 28 days.
* If you don't specify createdAt-start, the default is now - 28 days.
* If you don't specify createdAt-end, the default is now.
* If you search for a time > now, the default is now.
* If you search for a time before the retention period, the default is the retention period (now - 120 days).
* If createdAt-start >= createdAt-end, you will receive an error.


Sorting
---------------------------

The default sort order is always ascending. Ascending corresponds to the standard order of numbers and letters, i.e. A to Z, 0 to 9). For dates and times, ascending means that earlier values precede later ones e.g. 1/1/2000 will sort ahead of 1/1/2001.

All resource collections have a default sort order. In addition, some resources provide the ability to sort according to one or more criteria ("sort fields").

If sort fields are is prefixed with a minus, the order will be changed to descending.

**Javascript**

.. code-block:: javascript


  //The example below will return the oldest articles first:
  ".../matches?sort=createdAt"

  //The example below will return the newest articles first:
  ".../matches?sort=-createdAt"



JSON-P Callbacks
---------------------------

You can send a ``?callback`` parameter to any GET call to have the results wrapped in a JSON function. This is typically used when browsers want to embed content in web pages by getting around cross domain issues. The response includes the same data output as the regular API, plus the relevant HTTP Header information.

**Shell:**

.. code-block:: shell

  curl -g "https://api.dc01.gamelockerapp.com/status?callback=foo"




Cross Origin Resource Sharing
-----------------------------

This is what the CORS preflight request looks like. The API supports Cross Origin Resource Sharing (CORS) for AJAX requests from any origin. You can read the CORS W3C Recommendation, or this intro from the HTML 5 Security Guide.

Here's a sample request sent from a browser hitting http://example.com:

**Shell:**

.. code-block:: shell


  curl -i https://api.dc01.gamelockerapp.com/status -H "Origin: http://example.com"
  HTTP/1.1 200 OK
  ...
  Access-Control-Allow-Origin: *
  Access-Control-Expose-Headers: Content-Length

  This is what the CORS preflight request looks like:

  curl -i https://api.dc01.gamelockerapp.com/status -H "Origin: http://example.com" -X OPTIONS
  HTTP/1.1 200 OK
  ...
  Access-Control-Allow-Headers: Origin,X-Title-Id,Authorization
  Access-Control-Allow-Methods: GET,POST,OPTIONS
  Access-Control-Allow-Origin: *
  Access-Control-Max-Age: 86400




.. toctree::
  :maxdepth: 2