Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/insertish/freecycle-api
Library for fetching data from freecycle.org
https://github.com/insertish/freecycle-api
Last synced: 6 days ago
JSON representation
Library for fetching data from freecycle.org
- Host: GitHub
- URL: https://github.com/insertish/freecycle-api
- Owner: insertish
- Created: 2023-01-28T13:19:07.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-28T13:20:24.000Z (almost 2 years ago)
- Last Synced: 2024-10-15T04:22:58.291Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Freecycle API
Library for fetching data from freecycle.org
## Install
Add the package:
```bash
# npm
npm install freecycle-api# yarn
yarn add freecycle-api# pnpm
pnpm add freecycle-api
```## Usage
The library exports two functions `fetchTowns` and `fetchPosts`, which are both fully typed.
```javascript
import { fetchTowns, fetchPosts } from "freecycle-api";// Fetch all the towns available on Freecycle
const groupData = await fetchTowns();
// => { groups: { name: string, .. }, .. }// Fetch all the posts for a given town
const townData = await fetchPosts("BirminghamUK");
// => { posts: { id: string, .. }, .. }// Example: find all the available offers
const offersInBirmingham = townData.posts.filter(
({ type }) => type.const === "FC_POST_OFFER"
);
```