Giter Site home page Giter Site logo

102 / biketag-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from keneucker/biketag-api

0.0 0.0 0.0 15.99 MB

The javascript client for interacting with BikeTag games.

Home Page: https://keneucker.github.io/biketag-api/

License: GNU Affero General Public License v3.0

Shell 0.06% TypeScript 99.94%

biketag-api's Introduction

biketag

BikeTag Official JavaScript library

npm next version Build states
license
Sponsors Sponsors

Join the community on GitHub Discussions

biketag-api logo

Installation

This package is Isomorphic and Typescript ready

npm install biketag

How to include it in your projects

The library is a default export, as well as a named class export BikeTagClient. You can retrieve it from jsDeliver or npm, and it works in both the browser and nodejs.

Browser

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/biketag/client.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/npm/client.js"></script>

CommonJS

import/require the module:

// Using import statement
import { BikeTagClient } from 'biketag'
// Using require()
const { BikeTagClient } = require('biketag')

Usage

Instantiate with or without credentials (browser):

// if you have your clientKey/clientToken to retrieve an access token automatically, you can pass those in:
const client = new biketag({
  game: 'portland',
  clientKey: process.env.BIKETAG_CLIENT_KEY,
  clientToken: process.env.BIKETAG_CLIENT_TOKEN,
})

Instantiate with or without credentials (node):

// if you have Imgur credentials: clientId and clientSecret
const client = new BikeTagClient({
  game: 'portland',
  imgur: {
    clientId: process.env.IMGUR_CLIENT_ID,
    clientSecret: process.env.IMGUR_CLIENT_SECRET,
  }
})

Configuration

The BikeTag API requires only the game to be set in the configuration in order to read BikeTag data. You can read more about specific configurations in the documentation:

⚠️ For brevity, the rest of the examples will leave out the import and/or instantiation step.

Get Game Information

You can get game information by providing the name.

// retrieves the BikeTag game data 'portland' game
const biketagPortland = await client.game('portland')

Get Tags

You can get tags one by one or all at once for a given game using the getTag and getTags methods. You can also explicitely set the data adapter to any of the configurable sources (biketag, imgur, sanity):

// retrieves the BikeTag game data 'portland' game
const biketagPortland = await client.game('portland')

// retrieves the latest BikeTag posted for the 'portland' game from the most available API
const biketagPortlandCurrent = await client.getTag()

// retrieves the BikeTag #1 for the 'portland' game from imgur adapter
const biketagPortland1 = await client.tags(1, { source: 'imgur' })

// retrieves the all BikeTags for the 'portland' game from sanity adapter
const allPortlandTags = await client.tags(undefined, { source: 'sanity' })

Get Players

You can get the players of a game by calling getPlayers

// retrieves the BikeTag player data 'portland' game
const biketagPortlandPlayers = await biketagAPI.getPlayers('portland')

Credits

This project is heavily influenced by the node-imgur package, the Imgur API and it's documentation, and Sanity.IO's javascript client.

Using the typescript library configured and developed on the node-imgur v2 project: https://github.com/kaimallea/node-imgur, this package comes bundled with testing using jest and automated releases using github actions. Many thanks to Kaimallea for collaborating with me on the imgur API because I learned so much along the way!

Support the BikeTag Project on GitHub, Patreon, or directly by going out and playing a round of BikeTag in your city!

Alt

Vendors

Images powered by imgur.com

imgur.com

Structured Content powered by sanity.io

sanity.io

biketag-api's People

Contributors

102 avatar dependabot[bot] avatar ehoraizon avatar keneucker avatar nonara avatar septimiubloj avatar

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.