(Moved from https://github.com/publiclab/plots2/wiki/API/)
Our Swagger-generated API is quite extensive and growing. It can be easily accessed on the web interface and on the json guide.
To add any additional parameter, you can add the &
symbol followed by the field to the URL:
https://publiclab.org/api/srch/profiles?query=bob&limit=10
where limit
is an optional parameter.
All the endpoints have the optional parameter limit
(10 by default) where you can specify the number of results for your search. Below you have a description of the available endpoints.
-
URL:
https://publiclab.org/api/srch/all?query=bob
-
URL Params :
Required:
query=[string]
: search for notes, profiles, tags, questions and maps that match the query.
-
URL:
https://publiclab.org/api/srch/profiles?query=bob
-
URL Params :
Required:
query=[string]
: Search the profiles (users) that have the query on theirusername
andbio
profile info.Optional:
sort_by=[string]
: Sort the profiles by the most recent activity. If no value provided, the results are then sorted by user id (desc).order_direction=[string]
: It acceptsASC
orDESC
(the latter is the default).field=[string]
: Accepts the valueusername
for searching profiles only by the fieldusername
. And accepts the valuetag
for searching profiles by tag.
- URL:
https://publiclab.org/api/srch/notes?query=wind
- URL Params :
Required:
query=[string]
: Search for notes that have the passed string on their content.
- URL:
https://publiclab.org/api/srch/wikis?query=balloon
- URL Params :
Required:
query=[string]
: Search for wikis that have the passed string on their content.
-
URL:
https://publiclab.org/api/srch/questions?query=arduino
-
URL Params :
Required:
query=[string]
: Search for notes that have thequestion:query
on their tags list.
-
URL:
https://publiclab.org/api/srch/tags?query=wind
-
URL Params :
Required:
query=[string]
: Search the notes that have the query on their tags list.
-
URL:
https://publiclab.org/api/srch/taglocations?nwlat=200.0&selat=0.0&nwlng=0.0&selng=200.0
-
URL Params :
Required:
nwlat=[northwest latitude],selat=[southeast latitude],nwlng=[northwest longitude],selng=[southeast longitude]
: Search notes within the rectangle boundary made by these diagonally opposite coordinates.Optional:
tag=[string]
: The search can be refined by passing a tag field.order_direction=[string]
: It acceptsASC
orDESC
(the latter is the default).sort_by=[string]
: It acceptsrecent
. It sorts the nodes by the most recent activity. If no value provided, the results are then sorted by node creation (desc).from=[date]
: It accepts a date, if not specified (1990,01,01). It searches for nodes created from the date.to=[date]
: Accepts a date, if not specified usesnow
. It searches for nodes created by the specified date.
-
URL:
https://publiclab.org/api/srch/nearbyPeople?nwlat=200.0&selat=0.0&nwlng=0.0&selng=200.0
-
URL Params :
Required:
nwlat=[northwest latitude],selat=[southeast latitude],nwlng=[northwest longitude],selng=[southeast longitude]
: Search users within the rectangle boundary made by these diagonally opposite coordinates.Optional:
tag=[string]
: The search can be refined by passing a user tag field.field=[string]
: Accepts the valuenode_tag
for searching users following the node tag (topic). When the endpoint receives atag
as parameter by default it searches users with the specified user tag, this parameter switches the use of the tag parameter to link node tags instead.order_direction=[string]
: It acceptsASC
orDESC
(the latter is the default).sort_by=[string]
: It acceptsrecent
andcontent
. Sort the profiles by the most recent activity or most nodes created. If no value provided, the results are then sorted by signup date (desc).from=[date]
: It accepts a date. It searches for users with some activity from the specified date.to=[date]
: Accepts a date. It searches for users with some activity by the specified date.
We are beginning to consolidate API methods into the srch namespace, to reduce complexity in the non-API codebase and make the API more predictable and maintainable.
API methods are found on the Search class. This Search class is responsible to package the results into a DocResult.
We also have 3 services that aim to maintain the code more easier to change/maintain:
-
ExecuteSearch: responsible to execute the requested endpoint from the params.
-
SearchCriteria: responsible to validate the params.
-
SearchService: responsible to perform the endpoints queries.
We also have a Planning Issue if you want to contribute to the API.
This feature allows a logged user or bot to post comments via API with a token. You can generate your token to use this feature accessing your Profile on https://publiclab.org/profile/your-username (just make sure you are logged in).
This API method can be found here. You can see how to use this below:
-
URL:
/comment/create/token/id.:format
-
Method:
POST
-
URL Params :
Required:
id=[integer]
: This value specifies the node for which comment is to be createdformat=[string]
: Specifies response formatusername=[string]
: This string specifies username of user tends to create comment by this API post requestData Params:
body=[string]
: This is the actual content of the comment.Headers:
TOKEN=[string]
: This string value specifiesaccess_token
of the user for authentication purpose. -
Success Response:
- Code: 201 Created
Content: None
- Code: 201 Created
-
Error Response:
- Code: 400 BAD REQUEST
Content: None
- Code: 400 BAD REQUEST
-
Sample Call:
POST https://publiclab.org/comment/create/token/id.json Headers:- "HTTP_TOKEN": "7a969e3d-cfe1-4da5-9b4c-71a42c9eef88" Body: { "username": "user", "body": "This is a comment made with a token" }
RSS feeds can be found here.
- Authors: https://publiclab.org/feed/authorname.rss
- Tagged notes: https://publiclab.org/feed/tag/tagname.rss
- Main feed: https://publiclab.org/feed.rss
Tag-based listings can also be requested in JSON and XML formats:
- Notes by tag in JSON: https://publiclab.org/tag/balloon-mapping.json
- Wikis by tag in XML: https://publiclab.org/wiki/tag/place:*.xml
- Questions by tag in JSON: https://publiclab.org/questions/tag/spectrometry.json
- Maps by tag in XML: https://publiclab.org/maps/tag/gulf-coast.xml
To these last, you can do a wildcard tag search using the *
character, like this:
Several tag-based JSON/XML listings are generated directly from controllers, as alternate responses to various requests, ending in .json
or .xml
.