Coder Social home page Coder Social logo

api2's Introduction

Basic calls

# Ensure you can connect
curl https://api2.hackclub.com/ping
# returns "pong!"

# Get all records in a table
curl https://api2.hackclub.com/v0/Operations/Badges
# returns JSON array of records from 'Badges' table in 'Operations' base

# Planned for future release:
# Get specific record from a table
curl https://api2.hackclub.com/v0/Operations/Badges/rec9j291j3k928
# returns JSON object from airtable

Authorization

# Getting a protected route w/o using an auth token
curl https://api2.hackclub.com/v0/Operations/Addresses # or some other sensative data
# "ERROR: Tried to access table that is not in the whitelist."

# Lend your own Airtable API keys to get past the whitelist
curl -H "Authorization: Bearer VALID_AIRTABLE_KEY" https://api2.hackclub.com/v0/Operations/Addresses
# returns JSON array of non-whitelisted records from airtable

Filtering, searching

# The "select" URL param can be used to pass arguments into Airtable's API. A list of optional parameters are show below with examples

# Get only 1 record
curl https://api2.hackclub.com/v0/Operations/Badges?select={"maxResults":1}

# Get all badges, sorted by the number of people who have earned them
curl https://api2.hackclub.com/v0/Operations/Badges?select={"sort":[{"field":"People Count","direction":"desc"}]}

# You can combine arguments too. Here we'll sort badges by the number of people
# and select the single record at the top of the list to get the badge with the
# most users
curl https://api2.hackclub.com/v0/Operations/Badges?select={"sort":[{"field":"People Count","direction":"desc"}],"maxResults":1}

# You can select specific fields to return to speed up queries/only see the data you want:
curl https://api2.hackclub.com/v0/Operations/Badges?select={"fields":["Name"]}

Developing & Contributing

git clone https://github.com/hackclub/api2
cd api2/
pnpm install

# Run locally with nodemon
pnpm run dev
# Run tests
pnpm test

Development tools

# The `meta` url param will return a JSON object with metadata about the request you've just made
curl http://localhost:5000/v0/Operations/Clubs/?meta=true
# returns the following:
{
    result: [...], # Array of badges from Airtable
    meta: {
        duration: 241, # Time in ms to complete request
        query: {...}, # List of URL query params parsed by the server
        params: {...}, # List of URL params parsed by the server
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.