0.5.1 • Published 5 years ago

@techstars/client v0.5.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

@techstars/client

A handy, promise-based JavaScript client to consume, query and sort Techstars Public API data

Code Coverage

Coverage:branches

Coverage:functions

Coverage:lines

Coverage:statements

Using the Techstars client

Actually using the client is very straight forward. Pull in the dependency like so:

import { TechstarsAPI } from '@techstars/client'

const getStuff = async () => {
  try {
    const results = await TechstarsAPI.companies().get()
    return results.data
  } catch (error) {
    console.log(error)
  }
}

Currently the library only supports using async / await behaviors. We intend to support a .then() and .catch() method in the future

Important concepts

In most cases, the API client will request that you call a "noun" (companies, programs, etc) then provide a "verb", ie. get(). In between, you'll often have access to a variety of methods to refine your calls, things like .limit() and .query(). Check below for the full method list

And that's it! Each time the library is used it will instantiate a new instance for you.

Methods

Global query params

Any method provided by TechstarsAPI can be called with the following list of query() options, eg. TechstarsAPI.companies().query({ ...OPTIONS }).

const options = {
  // :integer, limits the number of returned responses
  limit: 1,
  // :integer, offsets the returned response by the passed value
  offset: 10,
  // :string, attribute by which to order the response 
  orderBy: 'sf_id',
  // :string, return only the comma-separated columns, defaults to returning `select *`
  select: 'id,sf_id',
}

await TechstarsAPI.companies().query({ ...options })

TechstarsAPI.companies()

Returns companies from the Techstars portfolio. To use it, simple call the TechstarsAPI.companies() method where required, and provide a few additional details.

Check Companies Constants for a full list of supported .query() fields

Filter methods:

  • .query(options: object): Object containing query paramters mapped to attributes, eg. program_status
  • .offset(number: integer): Offset the number of entries to return, convenience method for .query({ offset: INTEGER })
  • .limit(number: integer): Limit the number of responses, convenience method for .query({ limit: INTEGER }).

Action methods:

  • .get(): Retrieve from the Techstars API the specified companies information

Example of a full query:

const results = await TechstarsAPI.companies().query({program_status: 'in_program'}).limit(15).offset(0).get()

TechstarsAPI.mentors()

Returns mentors from the Techstars portfolio. To use it, simple call the TechstarsAPI.mentors() method where required, and provide a few additional details.

Check Mentors Constants for a full list of supported .query() fields

Filter methods:

  • .query(options: object): Object containing query paramters mapped to attributes, eg. accelerator_aim_id
  • .offset(number: integer): Offset the number of entries to return, convenience method for .query({ offset: INTEGER })
  • .limit(number: integer): Limit the number of responses, convenience method for .query({ limit: INTEGER }).

Action methods:

  • .get(): Retrieve from the Techstars API the specified mentors information

Example of a full query:

const results = await TechstarsAPI.mentors().query({session_aim_id: 'a1234f00b4r'}).limit(15).offset(0).get()

TechstarsAPI.sessions()

This method will return sessions from the API, as TechstarsAPI.sessions().

Check Sessions Constants for a full list of supported .query() fields

Filter methods:

  • .query(options: object): Object containing query paramters mapped to attributes, eg. program_status
  • .offset(number: integer): Offset the number of entries to return, convenience method for .query({ offset: INTEGER })
  • .limit(number: integer): Limit the number of responses, convenience method for .query({ limit: INTEGER }).

Action methods:

  • .get(): Retrieve from the Techstars API the specified sessions information

Example of a full query:

const results = await TechstarsAPI.sessions().query({program_status: 'Active'}).limit(15).offset(5).get()

TechstarsAPI.accelerators()

This method will return accelerators from the API, as TechstarsAPI.accelerators().

Check Accelerators Constants for a full list of supported .query() fields

Filter methods:

  • .query(options: object): Object containing query paramters mapped to attributes, eg. program_status
  • .offset(number: integer): Offset the number of entries to return, convenience method for .query({ offset: INTEGER })
  • .limit(number: integer): Limit the number of responses, convenience method for .query({ limit: INTEGER }).

Action methods:

  • .get(): Retrieve from the Techstars API the specified accelerators information

Example of a full query:

const results = await TechstarsAPI.accelerators().query({country: 'Ireland'}).limit(5).offset(0).get()

TODO

  • Fully explode available options for individual .query() paramters, eg. SessionsConstants.location accepts an array of values
0.5.1

5 years ago