swagger: "2.0"
info:
description: |
This is the REST API for [trashnothing.com](https://trashnothing.com).
To learn more about the API or to register your app for use with the API
visit the [Trash Nothing Developer page](https://trashnothing.com/app/developer).
NOTE: All date-time values are [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time)
and are in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) (eg. 2019-02-03T01:23:53).
version: "1.4"
title: Trash Nothing
termsOfService: >
https://trashnothing.com/terms
host: trashnothing.com
basePath: /api/v1.4
tags:
- name: users
description: Retrieve and update user data.
- name: posts
description: Retrieve and update posts.
- name: groups
description: Search, subscribe and unsubscribe to groups.
schemes:
- https
#
#
paths:
/users/{user_id}/posts:
get:
tags:
- users
summary: List posts by a user
description: >
operationId: get_user_posts
produces:
- application/json
parameters:
- name: user_id
in: path
description: >
The user ID of the user whose posts will be retrieved.
Using 'me' as the user_id will return the posts for the current user.
required: true
type: string
- name: sort_by
in: query
description: >
How to sort the posts that are returned. One of: date, active, distance
Date sorting will sort posts from newest to oldest.
Active sorting will sort active posts before satisfied, withdrawn and expired posts and then sort by date.
Distance sorting will sort the closest posts first.
required: false
default: date
type: string
- name: types
in: query
description: >
A comma separated list of the post types to return. The available post types are: offer, taken, wanted, received, admin
required: true
type: string
- name: sources
in: query
description: >
A comma separated list of the post sources to retrieve posts from. The available sources are:
groups, trashnothing, open_archive_groups.
The trashnothing source is for public posts that are posted on Trash Nothing but are not associated with any group.
The open_archive_groups source provides a way to easily request posts from groups that have open_archives set to true
without having to pass a group_ids parameter. When passed, it will automatically return posts from open archive groups
that are within the area specified by the latitude, longitude and radius parameters
(or all the open archive groups the requested user has posted to if
latitude, longitude and radius aren't passed).
NOTE: For requests using an api key instead of oauth, passing the trashnothing source or the open_archive_groups source
makes the latitude, longitude and radius parameters required.
required: true
type: string
- name: group_ids
in: query
description: >
A comma separated list of the group IDs to retrieve posts from.
This parameter is only used if the 'groups' source is passed in the sources parameter
and only groups that the current user is a member of or that are open archives groups
will be used (the group IDs of other groups will be silently discarded*).
NOTE: For requests using an api key instead of oauth, this field is required if the 'groups' source is passed.
In addition, only posts from groups that have open_archives set to true will be used
(the group IDS of other groups will be silently discarded*).
*To determine which group IDs were used and which were discarded, use the group_ids field in the response.
required: false
default: The group IDs of every group the current user is a member of.
type: string
- name: per_page
in: query
description: The number of posts to return per page (must be >= 1 and <= 100).
required: false
default: 20
minimum: 1
maximum: 100
type: integer
- name: page
in: query
description: The page of posts to return.
required: false
default: 1
minimum: 1
type: integer
- name: device_pixel_ratio
in: query
description: Client device pixel ratio used to determine thumbnail size (default 1.0).
required: false
default: 1.0
type: number
- name: latitude
in: query
description: >
The latitude of a point around which to return posts.
required: false
type: number
- name: longitude
in: query
description: >
The longitude of a point around which to return posts.
required: false
type: number
- name: radius
in: query
description: >
The radius in meters of a circle centered at the point defined by the latitude and longitude parameters.
When latitude, longitude and radius are passed, only posts within the circle defined by these parameters will be returned.
required: false
type: number
minimum: 0
maximum: 80500
- name: date_min
in: query
description: >
Only posts newer than or equal to this UTC date and time will be returned.
required: false
type: string
format: date-time
- name: date_max
in: query
description: Only posts older than this UTC date and time will be returned.
required: false
type: string
format: date-time
- name: outcomes
in: query
type: string
required: false
default: ''
description: >
A comma separated list of the post outcomes to return. The available post outcomes are: satisfied, withdrawn
There are also a couple special values that can be passed.
If set to an empty string (the default), only posts that are not satisfied and not withdrawn and not expired are returned.
If set to 'all', all posts will be returned no matter what outcome the posts have.
If set to 'not-promised', only posts that are not satisfied ant not withdrawn and not expired and not promised are returned.
#
- name: include_reposts
in: query
description: >
If set to 1 (the default), posts that are reposts will be included.
If set to 0, reposts will be excluded.
See the repost_count field of post objects for details about how reposts are identified.
required: false
default: 1
minimum: 0
maximum: 1
type: integer
responses:
200:
description: The posts and paging data.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/Post"
num_posts:
type: integer
description: The total number of posts available.
page:
type: integer
description: The page number of the posts being returned.
per_page:
type: integer
description: The number of posts being returned per page.
num_pages:
type: integer
description: The total number of pages available.
start_index:
type: integer
description: The index of the first post being returned (an integer between 1 and num_posts).
end_index:
type: integer
description: The index of the last post being returned (an integer between start_index and num_posts).
group_ids:
type: array
items:
type: string
description: >
The IDs of the groups that the posts were retrieved from (will be null when no group IDs were used).
These IDs may be a subset of the requested group IDs when a request includes group IDs for groups
that are not open archives and that the current user is not a member of. If the open_archive_groups
source is used, these IDs may include the IDs of open archive groups that weren't present in the
group_ids parameter of the request.
last_listings_view:
type: string
format: date-time
description: >
The UTC date and time when the current user last viewed the newest posts on the All Posts page (may be null).
NOTE: For this to be accurate, clients must update the last_listings_view property of the current user every time the user is shown
the newest posts on the All Posts page.
NOTE: For requests using an api key instead of oauth, this field is always null.
400:
description: Missing or invalid parameters.
security:
- api_key: []
/users/{user_id}/posts/search:
get:
tags:
- users
summary: Search posts by a user
description: >
Searching posts takes the same arguments as listing posts except for the addition of the search and sort_by parameters.
operationId: search_user_posts
produces:
- application/json
parameters:
- name: user_id
in: path
description: >
The user ID of the user whose posts will be retrieved.
Using 'me' as the user_id will return the posts for the current user.
required: true
type: string
- name: search
in: query
description: The search query used to find posts.
required: true
type: string
- name: sort_by
in: query
description: >
How to sort the posts that are returned. One of: relevance, date, active, distance
Relevance sorting will sort the posts that best match the search query first.
Date sorting will sort posts from newest to oldest.
Active sorting will sort active posts before satisfied, withdrawn and expired posts and then sort by date.
Distance sorting will sort the closest posts first.
required: false
default: relevance
type: string
- name: types
in: query
description: >
A comma separated list of the post types to return. The available post types are: offer, taken, wanted, received, admin
required: true
type: string
- name: sources
in: query
description: >
A comma separated list of the post sources to retrieve posts from. The available sources are:
groups, trashnothing, open_archive_groups.
The trashnothing source is for public posts that are posted on Trash Nothing but are not associated with any group.
The open_archive_groups source provides a way to easily request posts from groups that have open_archives set to true
without having to pass a group_ids parameter. When passed, it will automatically return posts from open archive groups
that are within the area specified by the latitude, longitude and radius parameters
(or all the open archive groups the requested user has posted to if
latitude, longitude and radius aren't passed).
NOTE: For requests using an api key instead of oauth, passing the trashnothing source or the open_archive_groups source
makes the latitude, longitude and radius parameters required.
required: true
type: string
- name: group_ids
in: query
description: >
A comma separated list of the group IDs to retrieve posts from.
This parameter is only used if the 'groups' source is passed in the sources parameter
and only groups that the current user is a member of or that are open archives groups
will be used (the group IDs of other groups will be silently discarded*).
NOTE: For requests using an api key instead of oauth, this field is required if the 'groups' source is passed.
In addition, only posts from groups that have open_archives set to true will be used
(the group IDS of other groups will be silently discarded*).
*To determine which group IDs were used and which were discarded, use the group_ids field in the response.
required: false
default: The group IDs of every group the current user is a member of.
type: string
- name: per_page
in: query
description: The number of posts to return per page (must be >= 1 and <= 100).
required: false
default: 20
minimum: 1
maximum: 100
type: integer
- name: page
in: query
description: The page of posts to return.
required: false
default: 1
minimum: 1
type: integer
- name: device_pixel_ratio
in: query
description: Client device pixel ratio used to determine thumbnail size (default 1.0).
required: false
default: 1.0
type: number
- name: latitude
in: query
description: >
The latitude of a point around which to return posts.
required: false
type: number
- name: longitude
in: query
description: >
The longitude of a point around which to return posts.
required: false
type: number
- name: radius
in: query
description: >
The radius in meters of a circle centered at the point defined by the latitude and longitude parameters.
When latitude, longitude and radius are passed, only posts within the circle defined by these parameters will be returned.
required: false
type: number
minimum: 0
maximum: 80500
- name: date_min
in: query
description: >
Only posts newer than or equal to this UTC date and time will be returned.
required: false
type: string
format: date-time
- name: date_max
in: query
description: Only posts older than this UTC date and time will be returned.
required: false
type: string
format: date-time
- name: outcomes
in: query
type: string
required: false
default: ''
description: >
A comma separated list of the post outcomes to return. The available post outcomes are: satisfied, withdrawn
There are also a couple special values that can be passed.
If set to an empty string (the default), only posts that are not satisfied and not withdrawn and not expired are returned.
If set to 'all', all posts will be returned no matter what outcome the posts have.
If set to 'not-promised', only posts that are not satisfied ant not withdrawn and not expired and not promised are returned.
#
- name: include_reposts
in: query
description: >
If set to 1 (the default), posts that are reposts will be included.
If set to 0, reposts will be excluded.
See the repost_count field of post objects for details about how reposts are identified.
required: false
default: 1
minimum: 0
maximum: 1
type: integer
responses:
200:
description: The posts and paging data.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/PostSearchResult"
num_posts:
type: integer
description: The total number of posts available.
page:
type: integer
description: The page number of the posts being returned.
per_page:
type: integer
description: The number of posts being returned per page.
num_pages:
type: integer
description: The total number of pages available.
start_index:
type: integer
description: The index of the first post being returned (an integer between 1 and num_posts).
end_index:
type: integer
description: The index of the last post being returned (an integer between start_index and num_posts).
group_ids:
type: array
items:
type: string
description: >
The IDs of the groups that the posts were retrieved from (will be null when no group IDs were used).
These IDs may be a subset of the requested group IDs when a request includes group IDs for groups
that are not open archives and that the current user is not a member of. If the open_archive_groups
source is used, these IDs may include the IDs of open archive groups that weren't present in the
group_ids parameter of the request.
400:
description: Missing or invalid parameters.
security:
- api_key: []
/groups:
get:
tags:
- groups
summary: Search groups
operationId: search_groups
produces:
- application/json
parameters:
- name: name
in: query
description: Find groups that have the given text somewhere in their name (case insensitive).
required: false
type: string
- name: latitude
in: query
description: Find groups near the given latitude and longitude.
required: false
type: number
- name: longitude
in: query
description: Find groups near the given latitude and longitude.
required: false
type: number
- name: distance
in: query
description: >
When latitude and longitude are passed, distance can optionally be passed to only
return groups within a certain distance (in kilometers) from the point specified
by the latitude and longitude. The distance must be > 0 and <= 150 and will
default to 100.
required: false
default: 100
minimum: 0
maximum: 150
type: number
- name: country
in: query
description: >
Find groups in the given country where country is a 2 letter country code for the
country (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ).
required: false
type: string
- name: region
in: query
description: >
For countries with regions (AU, CA, GB, US), search groups in a specific region as
specified by the region abbreviation. The supported regions and their abbreviations are listed below.
NOTE: The region and postal_code parameters cannot be used at the same time and if both
are passed then the postal_code will take priority.
---
**AU**
- QLD: Queensland
- SA: South Australia
- TAS: Tasmania
- VIC: Victoria
- WA: Western Australia
- NT: Northern Territory
- NSW: New South Wales - ACT
**CA**
- AB: Alberta
- BC: British Columbia
- MB: Manitoba
- NB: New Brunswick
- NL: Newfoundland and Labrador
- NS: Nova Scotia
- ON: Ontario
- QC: Quebec
- SK: Saskatchewan
- PE: Prince Edward Island
**GB**
- E: East
- EM: East Midlands
- LDN: London
- NE: North East
- NW: North West
- NI: Northern Ireland
- SC: Scotland
- SE: South East
- SW: South West
- WA: Wales
- WM: West Midlands
- YH: Yorkshire and the Humber
**US**
All 50 states and the District of Columbia are supported. For the abbreviations, see:
https://github.com/jasonong/List-of-US-States/blob/master/states.csv
required: false
type: string
- name: postal_code
in: query
description: >
Find groups in the given postal code. Only a few countries support postal code
searches (US, CA, AU, GB). The country parameter must be passed when the
postal_code parameter is set.
NOTE: The region and postal_code parameters cannot be used at the same time and if both
are passed then the postal_code will take priority.
required: false
type: string
- name: page
in: query
description: The page of groups to return.
required: false
default: 1
minimum: 1
type: integer
- name: per_page
in: query
description: The number of groups to return per page (must be >= 1 and <= 100).
required: false
default: 20
minimum: 1
maximum: 100
type: integer
responses:
200:
description: The groups and paging data.
schema:
type: object
properties:
groups:
type: array
items:
$ref: "#/definitions/Group"
num_groups:
type: integer
description: The total number of groups available.
page:
type: integer
description: The page number of the groups being returned.
per_page:
type: integer
description: The number of groups being returned per page.
num_pages:
type: integer
description: The total number of pages available.
start_index:
type: integer
description: The index of the first group being returned (an integer between 1 and num_groups).
end_index:
type: integer
description: The index of the last group being returned (an integer between start_index and num_groups).
400:
description: Missing or invalid parameters.
security:
- api_key: []
/groups/{group_id}:
get:
tags:
- groups
summary: Retrieve a group
operationId: get_group
produces:
- application/json
parameters:
- name: group_id
in: path
description: The ID of the group to retrieve.
required: true
type: string
responses:
200:
description: The group.
schema:
$ref: "#/definitions/Group"
404:
description: Group not found.
security:
- api_key: []
/groups/multiple:
get:
tags:
- groups
summary: Retrieve multiple groups
operationId: get_groups_by_ids
produces:
- application/json
parameters:
- name: group_ids
in: query
description: The IDs of the groups to retrieve. If more than 20 group IDs are passed, only the first 20 groups will be returned.
required: true
type: string
- name: latitude
in: query
description: >
If latitude and longitude are passed, each group returned will have a supported_point boolean property indicating
whether the group supports the point.
required: false
type: number
- name: longitude
in: query
description: >
If latitude and longitude are passed, each group returned will have a supported_point boolean property indicating
whether the group supports the point.
required: false
type: number
responses:
200:
description: The groups.
schema:
type: array
items:
$ref: "#/definitions/Group"
400:
description: Missing or invalid parameters.
security:
- api_key: []
/posts:
get:
tags:
- posts
summary: List posts
description: >
NOTE: When paging through the posts returned by this endpoint, there will be at most 1,000 posts that can be
returned (eg. 50 pages worth of posts with the default per_page value of 20). In areas where there are more
than 1,000 posts, clients can use more specific query parameters to adjust which posts are returned.
NOTE: Passing the latitude, longitude and radius parameters filters all posts by their location and so these
parameters will temporarily override the current users' location preferences.
When latitude, longitude and radius are not specified, public posts will be filtered by the current users'
location preferences.
operationId: get_posts
produces:
- application/json
parameters:
- name: sort_by
in: query
description: >
How to sort the posts that are returned. One of: date, active, distance
Date sorting will sort posts from newest to oldest.
Active sorting will sort active posts before satisfied, withdrawn and expired posts and then sort by date.
Distance sorting will sort the closest posts first.
required: false
default: date
type: string
- name: types
in: query
description: >
A comma separated list of the post types to return. The available post types are: offer, taken, wanted, received, admin
required: true
type: string
- name: sources
in: query
description: >
A comma separated list of the post sources to retrieve posts from. The available sources are:
groups, trashnothing, open_archive_groups.
The trashnothing source is for public posts that are posted on Trash Nothing but are not associated with any group.
The open_archive_groups source provides a way to easily request posts from groups that have open_archives set to true
without having to pass a group_ids parameter. When passed, it will automatically return posts from open archive groups
that are within the area specified by the latitude, longitude and radius parameters
(or the current users' location if
latitude, longitude and radius aren't passed).
NOTE: For requests using an api key instead of oauth, passing the trashnothing source or the open_archive_groups source
makes the latitude, longitude and radius parameters required.
required: true
type: string
- name: group_ids
in: query
description: >
A comma separated list of the group IDs to retrieve posts from.
This parameter is only used if the 'groups' source is passed in the sources parameter
and only groups that the current user is a member of or that are open archives groups
will be used (the group IDs of other groups will be silently discarded*).
NOTE: For requests using an api key instead of oauth, this field is required if the 'groups' source is passed.
In addition, only posts from groups that have open_archives set to true will be used
(the group IDS of other groups will be silently discarded*).
*To determine which group IDs were used and which were discarded, use the group_ids field in the response.
required: false
default: The group IDs of every group the current user is a member of.
type: string
- name: per_page
in: query
description: The number of posts to return per page (must be >= 1 and <= 100).
required: false
default: 20
minimum: 1
maximum: 100
type: integer
- name: page
in: query
description: The page of posts to return.
required: false
default: 1
minimum: 1
type: integer
- name: device_pixel_ratio
in: query
description: Client device pixel ratio used to determine thumbnail size (default 1.0).
required: false
default: 1.0
type: number
- name: latitude
in: query
description: >
The latitude of a point around which to return posts.
required: false
type: number
- name: longitude
in: query
description: >
The longitude of a point around which to return posts.
required: false
type: number
- name: radius
in: query
description: >
The radius in meters of a circle centered at the point defined by the latitude and longitude parameters.
When latitude, longitude and radius are passed, only posts within the circle defined by these parameters will be returned.
required: false
type: number
minimum: 0
maximum: 80500
- name: date_min
in: query
description: >
Only posts newer than or equal to this UTC date and time will be returned. If unset, defaults to the current date and time minus 90 days.
required: false
type: string
format: date-time
- name: date_max
in: query
description: Only posts older than this UTC date and time will be returned. If unset, defaults to the current date and time.
required: false
type: string
format: date-time
- name: outcomes
in: query
type: string
required: false
default: ''
description: >
A comma separated list of the post outcomes to return. The available post outcomes are: satisfied, withdrawn
There are also a couple special values that can be passed.
If set to an empty string (the default), only posts that are not satisfied and not withdrawn and not expired are returned.
If set to 'all', all posts will be returned no matter what outcome the posts have.
If set to 'not-promised', only posts that are not satisfied ant not withdrawn and not expired and not promised are returned.
#
- name: include_reposts
in: query
description: >
If set to 1 (the default), posts that are reposts will be included.
If set to 0, reposts will be excluded.
See the repost_count field of post objects for details about how reposts are identified.
required: false
default: 1
minimum: 0
maximum: 1
type: integer
responses:
200:
description: The posts and paging data.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/Post"
num_posts:
type: integer
description: The total number of posts available.
page:
type: integer
description: The page number of the posts being returned.
per_page:
type: integer
description: The number of posts being returned per page.
num_pages:
type: integer
description: The total number of pages available.
start_index:
type: integer
description: The index of the first post being returned (an integer between 1 and num_posts).
end_index:
type: integer
description: The index of the last post being returned (an integer between start_index and num_posts).
group_ids:
type: array
items:
type: string
description: >
The IDs of the groups that the posts were retrieved from (will be null when no group IDs were used).
These IDs may be a subset of the requested group IDs when a request includes group IDs for groups
that are not open archives and that the current user is not a member of. If the open_archive_groups
source is used, these IDs may include the IDs of open archive groups that weren't present in the
group_ids parameter of the request.
last_listings_view:
type: string
format: date-time
description: >
The UTC date and time when the current user last viewed the newest posts on the All Posts page (may be null).
NOTE: For this to be accurate, clients must update the last_listings_view property of the current user every time the user is shown
the newest posts on the All Posts page.
NOTE: For requests using an api key instead of oauth, this field is always null.
400:
description: Missing or invalid parameters.
security:
- api_key: []
/posts/search:
get:
tags:
- posts
summary: Search posts
description: >
Searching posts takes the same arguments as listing posts except for the addition of the search and sort_by parameters.
NOTE: When paging through the posts returned by this endpoint, there will be at most 1,000 posts that can be
returned (eg. 50 pages worth of posts with the default per_page value of 20). In areas where there are more
than 1,000 posts, clients can use more specific query parameters to adjust which posts are returned.
operationId: search_posts
produces:
- application/json
parameters:
- name: search
in: query
description: The search query used to find posts.
required: true
type: string
- name: sort_by
in: query
description: >
How to sort the posts that are returned. One of: relevance, date, active, distance
Relevance sorting will sort the posts that best match the search query first.
Date sorting will sort posts from newest to oldest.
Active sorting will sort active posts before satisfied, withdrawn and expired posts and then sort by date.
Distance sorting will sort the closest posts first.
required: false
default: relevance
type: string
- name: types
in: query
description: >
A comma separated list of the post types to return. The available post types are: offer, taken, wanted, received, admin
required: true
type: string
- name: sources
in: query
description: >
A comma separated list of the post sources to retrieve posts from. The available sources are:
groups, trashnothing, open_archive_groups.
The trashnothing source is for public posts that are posted on Trash Nothing but are not associated with any group.
The open_archive_groups source provides a way to easily request posts from groups that have open_archives set to true
without having to pass a group_ids parameter. When passed, it will automatically return posts from open archive groups
that are within the area specified by the latitude, longitude and radius parameters
(or the current users' location if
latitude, longitude and radius aren't passed).
NOTE: For requests using an api key instead of oauth, passing the trashnothing source or the open_archive_groups source
makes the latitude, longitude and radius parameters required.
required: true
type: string
- name: group_ids
in: query
description: >
A comma separated list of the group IDs to retrieve posts from.
This parameter is only used if the 'groups' source is passed in the sources parameter
and only groups that the current user is a member of or that are open archives groups
will be used (the group IDs of other groups will be silently discarded*).
NOTE: For requests using an api key instead of oauth, this field is required if the 'groups' source is passed.
In addition, only posts from groups that have open_archives set to true will be used
(the group IDS of other groups will be silently discarded*).
*To determine which group IDs were used and which were discarded, use the group_ids field in the response.
required: false
default: The group IDs of every group the current user is a member of.
type: string
- name: per_page
in: query
description: The number of posts to return per page (must be >= 1 and <= 100).
required: false
default: 20
minimum: 1
maximum: 100
type: integer
- name: page
in: query
description: The page of posts to return.
required: false
default: 1
minimum: 1
type: integer
- name: device_pixel_ratio
in: query
description: Client device pixel ratio used to determine thumbnail size (default 1.0).
required: false
default: 1.0
type: number
- name: latitude
in: query
description: >
The latitude of a point around which to return posts.
required: false
type: number
- name: longitude
in: query
description: >
The longitude of a point around which to return posts.
required: false
type: number
- name: radius
in: query
description: >
The radius in meters of a circle centered at the point defined by the latitude and longitude parameters.
When latitude, longitude and radius are passed, only posts within the circle defined by these parameters will be returned.
required: false
type: number
minimum: 0
maximum: 80500
- name: date_min
in: query
description: >
Only posts newer than or equal to this UTC date and time will be returned. If unset, defaults to the current date and time minus 90 days.
required: false
type: string
format: date-time
- name: date_max
in: query
description: Only posts older than this UTC date and time will be returned. If unset, defaults to the current date and time.
required: false
type: string
format: date-time
- name: outcomes
in: query
type: string
required: false
default: ''
description: >
A comma separated list of the post outcomes to return. The available post outcomes are: satisfied, withdrawn
There are also a couple special values that can be passed.
If set to an empty string (the default), only posts that are not satisfied and not withdrawn and not expired are returned.
If set to 'all', all posts will be returned no matter what outcome the posts have.
If set to 'not-promised', only posts that are not satisfied ant not withdrawn and not expired and not promised are returned.
#
- name: include_reposts
in: query
description: >
If set to 1 (the default), posts that are reposts will be included.
If set to 0, reposts will be excluded.
See the repost_count field of post objects for details about how reposts are identified.
required: false
default: 1
minimum: 0
maximum: 1
type: integer
responses:
200:
description: The posts and paging data.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/PostSearchResult"
num_posts:
type: integer
description: The total number of posts available.
page:
type: integer
description: The page number of the posts being returned.
per_page:
type: integer
description: The number of posts being returned per page.
num_pages:
type: integer
description: The total number of pages available.
start_index:
type: integer
description: The index of the first post being returned (an integer between 1 and num_posts).
end_index:
type: integer
description: The index of the last post being returned (an integer between start_index and num_posts).
group_ids:
type: array
items:
type: string
description: >
The IDs of the groups that the posts were retrieved from (will be null when no group IDs were used).
These IDs may be a subset of the requested group IDs when a request includes group IDs for groups
that are not open archives and that the current user is not a member of. If the open_archive_groups
source is used, these IDs may include the IDs of open archive groups that weren't present in the
group_ids parameter of the request.
400:
description: Missing or invalid parameters.
security:
- api_key: []
/posts/all:
get:
tags:
- posts
summary: List all posts
description: >
This endpoint provides an easy way to get a feed of all the publicly published posts on Trash Nothing.
It provides access to all publicly published offer and wanted posts from the last 30 days.
The posts are sorted by date (newest first).
There are fewer options for filtering, sorting and searching posts with this endpoint but there is no 1,000 post limit and
posts that are crossposted to multiple groups are not merged together in the response. In most
cases, crossposted posts are easy to detect because they have the same user_id, title and content.
operationId: get_all_posts
produces:
- application/json
parameters:
- name: types
in: query
description: >
A comma separated list of the post types to return. The available post types are: offer, wanted
required: true
type: string
- name: date_min
in: query
description: >
Only posts newer than or equal to this UTC date and time will be returned.
The UTC date and time used must be within a day or less of date_max.
And the date and time must be within the last 30 days.
And the date and time must be rounded to the nearest second.
required: true
type: string
format: date-time
- name: date_max
in: query
description: >
Only posts older than this UTC date and time will be returned.
The UTC date and time used must be within a day or less of date_min.
And the date and time must be rounded to the nearest second.
required: true
type: string
format: date-time
- name: per_page
in: query
description: The number of posts to return per page (must be >= 1 and <= 50).
required: false
default: 20
minimum: 1
maximum: 50
type: integer
- name: page
in: query
description: The page of posts to return.
required: false
default: 1
minimum: 1
type: integer
- name: device_pixel_ratio
in: query
description: Client device pixel ratio used to determine thumbnail size (default 1.0).
required: false
default: 1.0
type: number
responses:
200:
description: The posts.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/Post"
400:
description: Missing or invalid parameters.
security:
- api_key: []
/posts/all/changes:
get:
tags:
- posts
summary: List all post changes
description: >
This endpoint provides an easy way to get a feed of all the changes that have been made to publicly published posts
on Trash Nothing. Similar to the /posts/all endpoint, only data from the last 30 days is available and the changes
are sorted by date (newest first). Every change includes the date of the change, the post_id of the post that was changed
and the type of change.
The different types of changes that are returned are listed below.
- deleted
- undeleted
- satisfied
- promised
- unpromised
- withdrawn
- edited
For edited changes, clients can use the retrieve post API endpoint to get the edits that have been made to the post.
operationId: get_all_posts_changes
produces:
- application/json
parameters:
- name: date_min
in: query
description: >
Only changes newer than or equal to this UTC date and time will be returned.
The UTC date and time used must be within a day or less of date_max.
And the date and time must be within the last 30 days.
And the date and time must be rounded to the nearest second.
required: true
type: string
format: date-time
- name: date_max
in: query
description: >
Only changes older than this UTC date and time will be returned.
The UTC date and time used must be within a day or less of date_min.
And the date and time must be rounded to the nearest second.
required: true
type: string
format: date-time
- name: per_page
in: query
description: The number of changes to return per page (must be >= 1 and <= 50).
required: false
default: 20
minimum: 1
maximum: 50
type: integer
- name: page
in: query
description: The page of changes to return.
required: false
default: 1
minimum: 1
type: integer
responses:
200:
description: The changes.
schema:
type: object
properties:
changes:
type: array
items:
type: object
properties:
post_id:
type: string
date:
type: string
format: date-time
description: The UTC date and time when the post was changed.
type:
type: string
description: >
The type of change. One of: deleted, undeleted, satisfied, promised, unpromised, withdrawn, edited, expired
400:
description: Missing or invalid parameters.
security:
- api_key: []
/posts/{post_id}/display:
get:
tags:
- posts
summary: Retrieve post display data
description: >
Retrieve a post and other data related to the post that is useful for displaying
the post such as data about the user who posted the post and the groups the post was posted on.
operationId: get_post_and_related_data
produces:
- application/json
parameters:
- name: post_id
in: path
description: The ID of the post to retrieve.
required: true
type: string
responses:
200:
description: The post and related data.
schema:
type: object
properties:
post:
$ref: "#/definitions/Post"
author:
$ref: "#/definitions/User"
author_posts:
type: array
description: >
Other active posts from the post author in the last 90 days.
A maximum of 30 posts will be returned.
items:
$ref: "#/definitions/Post"
author_offer_count:
type: integer
description: Count of offer posts made by the post author in the last 90 days.
author_wanted_count:
type: integer
description: Count of wanted posts made by the post author in the last 90 days.
groups:
type: array
description: The groups the post is published on.
items:
$ref: "#/definitions/Group"
user_can_reply:
type: boolean
description: >
Whether or not the current user (if any) can reply to this post.
Unverified users cannot reply to posts until they verify their account.
viewed:
type: boolean
description: Whether or not the current user has previously viewed this post. Will be null for api key requests and for the current users' posts.
replied:
type: boolean
description: Whether or not the current user has replied to this post. Will be null for api key requests and for the current users' posts.
bookmarked:
type: boolean
description: Whether or not the current user has bookmarked this post. Will be null for api key requests and for the current users' posts.
hidden:
type: boolean
description: Whether the current user has hidden the post author.
403:
description: The user doesn't have permission to access the post.
404:
description: Post not found.
security:
- api_key: []
/posts/{post_id}:
get:
tags:
- posts
summary: Retrieve a post
operationId: get_post
produces:
- application/json
parameters:
- name: post_id
in: path
description: The ID of the post to retrieve.
required: true
type: string
responses:
200:
description: The post.
schema:
$ref: "#/definitions/Post"
403:
description: The user doesn't have permission to access the post.
404:
description: Post not found.
security:
- api_key: []
/posts/multiple:
get:
tags:
- posts
summary: Retrieve multiple posts
operationId: get_posts_by_ids
produces:
- application/json
parameters:
- name: post_ids
in: query
description: >
A comma separated list of the post IDs.
If more than 10 post IDs are passed, only the first 10 posts will be returned.
required: true
type: string
responses:
200:
description: The posts.
schema:
type: object
properties:
posts:
type: array
items:
$ref: "#/definitions/Post"
not_found:
description: The IDs of posts that weren't found (may have been deleted or never existed).
type: array
items:
type: string
forbidden:
description: The IDs of posts that are forbidden for the current user.
type: array
items:
type: string
security:
- api_key: []
securityDefinitions:
api_key:
type: apiKey
name: api_key
in: query
description: >
Provides access to specific public API endpoints which don't require user authorization.
NOTE: Some API endpoints behave differently when requests are made using api keys instead of oauth (because api key requests
have no user associated with them). Check the documentation for each endpoint for a description of the differences.
definitions:
PostSearchResult:
allOf:
- $ref: "#/definitions/Post"
- type: object
properties:
search_title:
type: string
description: >
The post subject as HTML with the parts of the subject that matched the search
query (if any) wrapped in HTML span tags with the class 'highlight'.
(eg. <span class="highlight">matched words</span>). May be null if
none of the words in the subject matched the search query.
search_content:
type: string
description: >
A snippet of the post content as HTML with the parts of the content that matched the search
query (if any) wrapped in an HTML span tags with the class 'highlight' (eg. <span class="highlight">matched words</span>).
May be null if none of the words in the post content matched the search query.
NOTE: This is not the full content of the post It is just a snippet of around 200 characters that can be
used to display the parts of the post content relevant to the search query.
example:
post_id: 25997431
group_id: 81
user_id: 82928
title: Microwave Oven (Greenfield)
content: >
Panasonic microwave oven in good working order
800 W power and turntable inside
Has all the normal microwave functions plus grill elements for browning
Comes with original instructions booklet
It's an old microwave and could do with a bit of a clean, but still works very well
date: "2018-02-18T17:11:38"
type: offer
outcome: null
latitude: 42.961404
longitude: -88.012586
footer: null
photos: null
expiration: "2018-04-18T17:11:38"
reselling: false
url: https://trashnothing.com/post/25997431/microwave-oven-greenfield
repost_count: 0
search_title: Microwave Oven (Greenfield)
search_content: Panasonic microwave oven in good working order 800 W power and turntable
Photo:
type: object
properties:
photo_id:
type: string
thumbnail:
type: string
description: A URL to a thumbnail of this photo. The size of the thumbnail depends on the device_pixel_ratio parameter and it is not guaranteed to be square.
url:
type: string
description: A URL to a large version of this photo (but not necessarily the largest size available).
blurhash:
type: string
description: >
A blurhash of the photo that can be used as a placeholder while the photo is loading (see: https://github.com/woltapp/blurhash).
May be null if no blurhash is available and the length of the blurhash can vary based on the photo.
avif:
type: boolean
description: >
Whether avif versions of the image are available. If they are, the avif image can be loaded by changing the extension
on any of the image URLs to 'avif'.
images:
type: array
description: All the versions of this photo ordered from smallest to largest. This list is guaranteed to include the photos specified by the above thumbnail and url properties.
items:
type: object
properties:
url:
type: string
width:
type: integer
height:
type: integer
example:
photo_id: 695624-768616
thumbnail: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.90x120.jpg
url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.375x500.jpg
blurhash: 'TkJ7jsoz%f~VoLxu-pWCWB-oj[M|'
images:
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.90x120.jpg
width: 90
height: 120
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.180x240.jpg
width: 180
height: 240
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.270x360.jpg
width: 270
height: 360
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.375x500.jpg
width: 375
height: 500
Post:
description: An offer, wanted, admin, taken or received post.
type: object
properties:
post_id:
type: string
source:
type: string
description: >
The source of the post. One of: groups, trashnothing, open_archive_groups. A value of groups
or open_archive_groups indicates the post is from a group and the group_id field will contain the ID of the group.
A value of trashnothing indicates the post is a public post not associated with any group.
group_id:
type: string
description: >
The group ID of the post. For public posts, this is always null.
user_id:
type: string
title:
type: string
content:
type: string
date:
type: string
format: date-time
description: The UTC date and time when the post was published.
type:
type: string
description: >
The type of post. One of: offer, taken, wanted, received, admin
outcome:
type: string
description: >
For offer and wanted posts, this indicates the outcome of the post which is null
if no outcome has been set yet.
Offer post outcomes will be one of: satisfied, withdrawn, promised, expired
Wanted post outcomes will be one of: satisfied, withdrawn, expired
For all other posts, outcome is always null.
latitude:
type: number
description: May be null if a post hasn't been mapped.
longitude:
type: number
description: May be null if a post hasn't been mapped.
footer:
type: string
description: Some groups add footers to posts that are separate and sometimes unrelated to the post itself - such as reminders about group rules or features (may be null).
photos:
type: array
description: Details about the photos associated with this post (may be null if there are no photos).
items:
$ref: "#/definitions/Photo"
expiration:
type: string
format: date-time
description: >
The UTC date and time when the post will expire.
Currently only offer and wanted posts expire. For all other posts, expiration is always null.
reselling:
type: boolean
description: >
For wanted posts, whether the item is being requested in order to resell it or not.
Will be null for all posts that are not wanted posts and for wanted posts where the poster hasn't
indicated whether or not they intend to resell the item they are requesting.
url:
type: string
description: The link to use to view the post on the Trash Nothing site.
repost_count:
type: integer
description: >
The count of how many times this post has been reposted in the last 90 days.
A value of zero is used to indicate that the post is not a repost.
The count is specific to the source of the post (eg. the specific group the post is on).
If a post is crossposted to multiple groups, the repost_count of the post on each group may
be different for each group depending on how many times the post has been posted on that group
in the last 90 days.
example:
post_id: 3171898
group_id: 6
user_id: 2933
title: Ultrasonic diffuser (Downtown Toronto)
content: This ultrasonic diffuser creates an aroma in your home. It comes with two essential oils - mint and lavender.
date: "2018-02-05T15:10:21"
type: offer
outcome: satisfied
latitude: 43.653226
longitude: -79.383184
footer: null
photos:
- photo_id: 695624-768616
thumbnail: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.90x120.jpg
url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.375x500.jpg
images:
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.90x120.jpg
width: 90
height: 120
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.180x240.jpg
width: 180
height: 240
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.270x360.jpg
width: 270
height: 360
- url: https://trashnothing.com/img/2018-02-05/cfsbfm-39051735845_379baab73f.375x500.jpg
width: 375
height: 500
expiration: "2018-03-05T15:10:21"
reselling: false
url: https://trashnothing.com/post/3171898/ultrasonic-diffuser-downtown-torronto
repost_count: 1
Group:
description: >
Groups are run by volunteer moderators and provide a way to group activity in a specific location.
Because each group is usually run by different people, there can be variations in rules from group
to group (eg. who is allowed to join, what is allowed to be posted, how often reposts are allowed).
type: object
properties:
group_id:
type: string
name:
type: string
description: The name of the group (not guaranteed to be unique).
identifier:
type: string
description: A unique identifier for the group that is used in URLs.
homepage:
type: string
description: A URL to the group homepage.
member_count:
type: integer
description: The number of members who belong to the group.
latitude:
type: number
longitude:
type: number
timezone:
type: string
description: The timezone that the group is in (eg. America/New_York).
#
open_membership:
type: boolean
description: When true, the group allows anyone to join. When false, the group moderators review and approve applicants.
open_archives:
type: boolean
description: When true, the group posts are viewable by anyone. When false, the group posts can only be viewed by members of the group.
has_questions:
type: boolean
description: When true, anyone requesting membership to this group will be required to answer a new membership questionnaire.
country:
type: object
description: Provides information about the country that is associated with a group. May be null.
properties:
name:
type: string
description: The name of the country.
abbreviation:
type: string
description: >
A 2 letter country code for the country (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ).
example:
name: United States
abbreviation: US
region:
type: object
description: Provides information about an area within a country that a group is associated with (eg. a state in the US or a province in Canada). May be null.
properties:
name:
type: string
description: The name of the region.
abbreviation:
type: string
description: A 2 letter abbreviation for the region (is not guaranteed to be globally unique but is unique among all the regions in the country).
example:
name: California
abbreviation: CA
membership:
type: object
description: >
Provides information about the current users' active or pending membership to this group (if any).
Will be null if there is no active or pending membership to this group.
properties:
status:
type: string
description: >
One of: subscribed, pending, pending-questions
date:
type: string
format: date-time
description: >
The UTC date and time when the membership was last updated.
questionnaire:
type: object
description: Membership questionnaire data. Will be null unless the membership status is pending-questions.
properties:
message:
type: string
description: A message from the group moderators to be displayed above the questions (may be null).
questions:
type: array
description: The list of questions.
items:
type: string
example:
group_id: 46
name: Ottawa Reuse
identifier: OttawaReuse
homepage: https://trashnothing.com/OttawaReuse
member_count: 4838
latitude: 45.423494
longitude: -75.697933
timezone: America/Toronto
open_membership: false
open_archives: false
has_questions: true
country:
name: Canada
abbreviation: CA
region:
name: Ontario
abbreviation: ON
membership:
status: pending-questions
date: "2015-01-22T17:05:50"
questionnaire:
message: This group is only for people who live in Ottawa.
questions:
- Where do you live?
Feedback:
type: object
properties:
feedback_id:
type: string
user_id:
type: string
description: The user ID of the user that the feedback is about.
reviewer_user_id:
type: string
description: The user ID of the user that submitted the feedback.
content:
type: string
description: A comment written by the reviewer about the user (may be null).
positive:
type: boolean
description: Set to true for positive feedback and false for negative feedback.
date:
type: string
format: date-time
description: Date when the feedback was submitted.
example:
user_id: 2946512
reviewer_user_id: 9191
content: Fred gave me a great antique table for my new apartment!
positive: true
date: "2020-03-01T12:01:22"
User:
type: object
properties:
user_id:
type: string
username:
type: string
description: >
A username that can be displayed for the user (the username is NOT guaranteed to be unique).
Will be null for api key requests and requests where the oauth user doesn't belong to any of the same groups
as this user.
country:
type: string
description: >
A 2 letter country code for the country that has been automatically detected for the user (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ). May be null if no country has been set.
profile_image:
type: string
description: >
A URL to a profile image for the user. Profile images sizes vary based on the source (Google, Facebook, Gravatar, etc)
and some can be as small as 64px by 64px. Will be null for api key requests and requests where the oauth user doesn't belong
to any of the same groups as this user.
member_since:
type: string
description: The date and time when the user first became publicly active on a group (the date may be older than when the user signed up).
firstname:
type: string
description: The first name of the user (may be null).
lastname:
type: string
description: The last name of the user (may be null).
reply_time:
type: integer
description: >
An estimate of how many seconds it takes this user to reply to messages.
May be null when there is not enough data to calculate an estimate.
feedback:
type: object
properties:
restriction:
type: string
description: >
If the current user can leave positive or negative feedback on this user then restriction is null.
Otherwise, restriction is set to a string that explains why feedback is currently restricted and
what type of feedback is restricted. The string will be one of the following:
no-recent-messages, negative-score, moderator, [days]-day-wait-for-negative
- **no-recent-messages**: The current user has not received any messages from this user in the last 30 days.
- **negative-score**: The current user has a negative feedback and will not be able to leave feedback until their score is >= 0.
- **moderator**: The user is a moderator and leaving feedback on moderators is not currently supported.
- **[days]-day-wait-for-negative**: Positive feedback is not restricted but the current user must wait
some number of days before they will be able to leave negative feedback on this user. This string can
change depending on the number of days. For example, when the current user must wait one day, the
string will be '1-day-wait-for-negative'. A wait is necessary because a lot of negative feedback results
from communication issues that are resolved with more time.
score:
type: integer
description: >
The feedback score of this user. Higher scores are better.
Scores are calculated by substracting the total number of negative feedback from the total number of positive feedback
that a user has received. May be null if a user has not received enough feedback to calculate a score.
percent_positive:
type: number
description: >
The percent of feedback that this user has received in the last year that was positive.
May be null if a user has not received enough feedback to calculate a percentage.
minimum: 0
maximum: 100
about_me:
type: string
description: >
A short bio a user has written about themselves to help other members get to know them better.
May be null if the user has not written anything about themselves.
example:
user_id: 2946512
username: fred gibson
country: GB
profile_image: https://lh3.googleusercontent.com/-1qVLzuOCyYg/AAAAAAAAAAI/AAAAAAAAAAA/0aGNzRAO61c/s64-c/100783935580725962164.jpg
member_since: "2017-01-27T06:35:55"
firstname: null
lastname: null
reply_time: 4850
feedback:
restriction: no-recent-messages
score: 7
percent_positive: 87.5
about_me: Just an old fisherman looking to reuse more.
#