v1

latestSwagger 2.02026-07-1312672.0 KB
posts

Search posts

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.

get/posts/search

Query parameters

searchstring required

The search query used to find posts.

sort_bystring

How to sort the posts that are returned. One of: relevance, date, active, distance <br /><br /> 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.

typesstring required

A comma separated list of the post types to return. The available post types are: offer, wanted, admin

sourcesstring required

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). <br /><br /> 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.

group_idsstring

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*). <br /><br /> 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*). <br /><br/> *To determine which group IDs were used and which were discarded, use the group_ids field in the response.

per_pageinteger

The number of posts to return per page (must be >= 1 and <= 100).

pageinteger

The page of posts to return.

device_pixel_rationumber

Client device pixel ratio used to determine thumbnail size (default 1.0).

latitudenumber

The latitude of a point around which to return posts.

longitudenumber

The longitude of a point around which to return posts.

radiusnumber

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.

date_minstring date-time

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.

date_maxstring date-time

Only posts older than this UTC date and time will be returned. If unset, defaults to the current date and time.

outcomesstring

A comma separated list of the post outcomes to return. The available post outcomes are: satisfied, withdrawn <br /><br /> 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.

include_repostsinteger

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.

Response

The posts and paging data.

num_postsinteger

The total number of posts available.

pageinteger

The page number of the posts being returned.

per_pageinteger

The number of posts being returned per page.

num_pagesinteger

The total number of pages available.

start_indexinteger

The index of the first post being returned (an integer between 1 and num_posts).

end_indexinteger

The index of the last post being returned (an integer between start_index and num_posts).

group_idsstring[]

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.

Example response

{
  "posts": [
    {
      "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\n",
      "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": "<span class=\"highlight\">Microwave</span> Oven (Greenfield)",
      "search_content": "Panasonic <span class=\"highlight\">microwave</span> oven in good working order 800 W power and turntable"
    }
  ]
}