3.4 KiB
3.4 KiB
magneticow API v0 Documentation
Status: Draft (NOT Finalised)
Last Updated: 13 June 2017 by Bora M. Alper.
General remarks
- All requests MUST be encoded in UTF-8 and same applies for responses too.
- Clients MUST set
Content-type
header toapplication/json; charset=utf-8
for all their requests.
- Clients MUST set
- All dates MUST be in ISO 8601 format, same applies for responses too.
Collections
/torrents
, representing all the torrents in the database./statistics
, representing all the statistical data about the database.
Methods defined on /torrents
collection
GET
Parameters:
query
: string to be queried in the torrent titles. If absent, all torrents will be returned.- ATTENTION:
query
MUST NOT be an empty string, if supplied. - Remark: The format of the
query
is to be clarified! [TODO]
- ATTENTION:
limit
: number of results to be returned per page. If absent, it's by default 20.sort_by
: string enum, MUST be one of the stringsdiscovered_on
,relevance
(ifquery
is non-empty),size
, separated by space, and followed by one of the stringsASC
orDESC
, for ascending and descending, respectively.- ATTENTION: If
sort_by
isrelevance
,query
is MUST be supplied.
- ATTENTION: If
Response:
- Status code:
200 OK
[
{
"info_hash": "ABCDEFABCDEFABCDEFAB",
"title": "EXAMPLE TITLE",
"discovered_on": "2017-06-13T14:06:01Z",
"files": [
{"path": "file.ext", "size": 1024},
{"path": "directory/file_2.ext", "size": 2048},
{"path": "directory/file_3.ext", "size": 4096},
...
]
},
...
]
info_hash
is a hex-encoded info hash of the torrent.discovered_on
is the date the torrent is discovered on.- ATTENTION: Due to ambiguities about
time()
function in the C standard library, the effect of leap seconds, and (being pedantic) even the epoch is platform-dependent. (The epoch is quite often 1970-01-01T00:00:00Z.)
- ATTENTION: Due to ambiguities about
files
is a list of files denoted by their relative-paths./
character (U+002F) is used as a path separator, hence it can be safely assumed that none of the directory or file name can contain it.\0
(U+0000) is also prohibited to appear anywhere in the path.- Remark: These restrictions are not in the BitTorrent specifications. So how magnetico enforces that? Well, magneticod simmply ignores torrents with illegal file names!
Methods defined on /statistics
collection
GET
Parameters:
group_by
: is how data-points are grouped by; MUST be one of the stringshour
,day
,week
,month
, oryear
.period
: is two dates, separated by a space chaacter (U+0020), denoting start and end, both inclusive.- ATTENTION: Depending on the
group_by
,datetime
WILL be in one of the following formats:yyyy
foryear
(e.g.2017
)yyyy-mm
formonth
(e.g.2017-06
)yyyy-Ww
forweek
(e.g.2017-W25
)yyyy-mm-dd
forday
(e.g.2017-06-04
)yyyy-mm-ddThh
forhour
(e.g.2017-06-04:02
)
- ATTENTION: Depending on the
Response:
- Status code:
200 OK
[
{
"datetime": "2017-06",
"new_torrents": 2591558
},
{
"datetime": "2017-07",
"new_torrents": 3448754
},
...
]
datetime
is the date (and if applicable, time) of a data-point.- Remark: Depending on the
group_by
,datetime
WILL have the same format withperiod
.
- Remark: Depending on the