Skip to content

Commit bb83757

Browse files
authored
Merge pull request #15 from Wikidocumentaries/feat/api-documentation
Document the main API endpoints in README
2 parents c528eef + 8bb0744 commit bb83757

File tree

1 file changed

+115
-7
lines changed

1 file changed

+115
-7
lines changed

README.md

Lines changed: 115 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# wikidocumentaries-api
22

3-
Provide APIs for the UI for the following purposes:
3+
Provides REST APIs and a backend service for the Wikidocumentaries UI for the following purposes:
44

5-
* Mediawiki APIs require a custom User-Agent header.
5+
* Fetch data from both Wikipedia and Wikidata when given an id from either.
66

7-
* Wikidata Query Service (WDQS) does not provide an Access-Control-Allow-Origin header.
7+
* Search for images from various sources with one request.
8+
9+
* Find related data from Wikidata and other wikibases using SPARQL queries.
10+
11+
* Set a custom User-Agent header as required by Mediawiki APIs.
12+
13+
* Work around Wikidata Query Service (WDQS) not providing an Access-Control-Allow-Origin header.
814

915
* etc.
1016

17+
Also see the section [Provided endpoints](#provided-endpoints) below.
18+
1119
## Docker
1220

1321
You can run this service as a container with
@@ -20,18 +28,118 @@ You can build a new version of the container image with
2028

2129
## Install
2230

31+
```
2332
npm install
33+
```
2434

25-
## Run
35+
## Run in development mode
2636

37+
```
2738
npm run dev
39+
```
2840

29-
## Remarks
41+
## Run in production mode
3042

31-
Some environment variables must be set.
43+
```
44+
npm start
45+
```
3246

33-
* WIKIDOCUMENTARIES_API_USER_AGENT: Please see https://en.wikipedia.org/api/rest_v1/
47+
## Environment variables
48+
49+
Some API keys should be set as environment variables:
50+
51+
* WIKIDOCUMENTARIES_API_USER_AGENT (required): Please see https://en.wikipedia.org/api/rest_v1/
3452

3553
* BING_MAPS_KEY (optional)
3654

3755
* FLICKR_KEY (optional)
56+
57+
## Provided endpoints
58+
59+
The main API endpoints:
60+
61+
* /wiki
62+
* Parameters (provide either wikidata or topic):
63+
* language: language code
64+
* wikidata: id of the Wikidata item
65+
* topic: title of the Wikipedia article
66+
* Response:
67+
* wikidata
68+
* id
69+
* title
70+
* description
71+
* aliases
72+
* instance_of
73+
* statements
74+
* geo
75+
* dates
76+
* sitelinks
77+
* wikipedia
78+
* type
79+
* title
80+
* displaytitle
81+
* namespace
82+
* wikibase_item
83+
* titles
84+
* pageid
85+
* thumbnail
86+
* originalimage
87+
* lang
88+
* dir
89+
* revision
90+
* tid
91+
* timestamp
92+
* description
93+
* description_source
94+
* coordinates
95+
* content_urls
96+
* extract
97+
* extract_html
98+
* wikipediaExcerptHTML
99+
* wikipediaRemainingHTML
100+
101+
* /images
102+
* Parameters:
103+
* language: language code
104+
* topic: search string
105+
* commons_category: if provided, return everything from this category in Wikimedia Commons; without the prefix "Category:"
106+
* lat, lon: coordinates to search around
107+
* maxradius: radius around the coordinates
108+
* Response:
109+
* a list of images:
110+
* source
111+
* id
112+
* title
113+
* imageURL
114+
* thumbURL
115+
* infoURL
116+
* license
117+
* license_link
118+
* inventoryNumber
119+
* geoLocations
120+
* location
121+
* measurements
122+
* materials
123+
* formats
124+
* year
125+
* publisher
126+
* creators
127+
* institutions
128+
* actors
129+
* details
130+
* subjects
131+
* places
132+
* collection
133+
* imageRights
134+
* description
135+
* inscriptions
136+
* datecreated
137+
* uploader
138+
* collection
139+
* language
140+
141+
* /sparql
142+
* Parameters (following the standard for SPARQL queries):
143+
* query
144+
* format
145+
* Response depending on format

0 commit comments

Comments
 (0)