-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocumentation.php
147 lines (123 loc) · 4.5 KB
/
documentation.php
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
<pre>
Documentation - WikiJourney API
This documentation refers to the API of Wikijourney's website.
You can enter a position (latitude and longitude), it will return
the point of interest around, with informations, including POI
type, description, and link to the Wikipedia's page when available.
Since the Alpha 0.0.3 version, this API is also able to look for
WikiVoyage guides around the user's position.
This API is based on datas from Wikipedia, Wikidata, Wikivoyage,
and use the OSM Nominatim.
-------------> VERSIONS :
RELEASE
2.0 : Complete refactoring making the API way more efficient. Temporarly disabled the cache.
1.0 : API fully fonctional.
BETA
1.2.0 : Changed cache requests to prepared statements. Better langugages support.
1.1.1 : Minor bugfix and error gestion.
1.1.0 : Added Cache support. The API is now a lot quicker if POI have already been visited.
1.0.0 : Added thumbnail for POIs. New technology implemented, making the API faster.
ALPHA
0.0.5 : Added the fake error function.
0.0.4 : Added Nominatim support
0.0.3 : Added WikiVoyage informations.
0.0.2 : Error gestion. More information in the output.
0.0.1 : Creation of the API. Export in JSON.
-------------> INPUT :
Use this link : http://api.wikijourney.eu/?PARAMETERS
Parameters could be (INS is for If Not Specified) :
- [REQUIRED] lat : user's latitude
- [REQUIRED] long : user's longitude
- [OPTIONAL] place : If you want to do a request with a place name instead of coordinates. Uses OSM nominatim system.
- [INS 5 ] range : Range around we're gonna find POI in kilometers
- [INS 50 ] maxPOI : number max of POI
- [INS en ] lg : language used
- [INS 0 ] wikivoyage : contact or no WikiVoyage API. Value 0 or 1.
- [INS 20 ] wikiVoyageRange : range to look for wikivoyage guides around, in kilometers.
- [INS 500 ] thumbnailWidth : maximum width of thumbnails from Wikipedia's article. Value is in px, and has to be numeric.
- [OPTIONAL] fakeError : use it if you need to test error on your device. It will simulate an error during the process.
Example : http://api.wikijourney.eu/?lat=2&lon=2&lg=fr
Example : http://api.wikijourney.eu/?place=Washington&lg=en&wikivoyage=1
-------------> OUTPUT :
The output is a JSON array. You can obtain it using curl, file_get_contents, wget or whatever.
Structure :
- infos
- source
- link
- api_version
- user_location
- latitude
- longitude
- guides ==> Available only if wikivoyage=1
- nb_guides
- guides_info ==> Contains the array with informations on WikiVoyage's guides
- pageid
- title
- sitelink
- latitude
- longitude
- thumbnail (link to thumbnail - could be null)
- poi
- nb_poi
- poi_info ==> Contains the array with informations on POIs
- id (Wikipedia ID)
- name
- latitude
- longitude
- distance (Distance in meters from user's position)
- sitelink (could be null)
- wikidata_id (id of the Wikidata page)
- image_url (link to thumbnail - could be null)
- type_id
- type_name
- err_check
- value (true if there's an error)
- msg (defined only if value is set on true) : contains the error message
-------------> EXAMPLE :
Input : http://api.wikijourney.eu/?wikivoyage=1&place=Lille&lg=en&maxPOI=1
Output :
{
"infos":{
"source":"WikiJourney API",
"link":"https:\/\/www.wikijourney.eu\/",
"api_version":"v2.0"
},
"user_location":{
"latitude":"50.6305089",
"longitude":"3.0706414"
},
"guides":{
"nb_guides":1,
"guides_info":[
{
"pageid":19684,
"title":"Lille",
"sitelink":"https:\/\/en.wikivoyage.org\/wiki\/Lille",
"latitude":50.6372,
"longitude":3.0633,
"thumbnail":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/7\/77\/Lille-Place-du-General-de-Gaulle.jpg\/144px-Lille-Place-du-General-de-Gaulle.jpg"
}
]
},
"poi":{
"nb_poi":1,
"poi_info":[
{
"id":24374320,
"name":"Siege of Lille (1792)",
"latitude":50.627777777778,
"longitude":3.0583333333333,
"distance":919.7,
"sitelink":"https:\/\/en.wikipedia.org\/wiki\/Siege_of_Lille_(1792)",
"wikidata_id":"Q3485925",
"image_url":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/b\/b6\/Si%C3%A8ge_de_Lille_1792.JPG\/500px-Si%C3%A8ge_de_Lille_1792.JPG",
"type_id":188055,
"type_name":"siege"
}
]
},
"err_check":{
"value":false
}
}
</pre>