Giter Club home page Giter Club logo

github_api's Introduction

GitHub API

Small service that scrapes User and Repository data from GitHub and stores the data in a database. This service expose a query API that accepts parameters relevant to the data and returns a well-formed API object.

Installation

This steps are necessary to get the application up and running.

It requires Ruby 2.6.3 and Mongo 4.0 previous installed to run. Check this gist to have the pre requisites installed on MacOSX.

$ cd github_api
$ bundle install
$ rake db:setup
$ rake db:create_indexes
$ rails s

Scraping github data

The followings steps are necessary to connect to GitHub’s API to scrape and store Repository and User data.

Fetching current user data

$ cd github_api
$ rake "github:fetch_me" GITHUB_ACCESS_TOKEN=your_top_secret_access_token

Fetching others public user data

$ cd github_api
$ rake "github:fetch[felipetio,fabiofleitas]" GITHUB_ACCESS_TOKEN=your_top_secret_access_token

Cronjobs

To schedule cronjobs to scrape more data you can add a .env file with your token to protected it. GITHUB_ACCESS_TOKEN=your_top_secret_access_token

Now you can add the following comand in you corntab: cd path/to/github_api && bundle exec rake github:fetch_me

Query Format

The query format is designed to be simple and readable in the URL, it follows these rules:

  • All query parameters are encapsulate in a dict, keys are assumed to be field names
  • Special query parameters sort, limit and offset are treated specially, any other query parameter is ignored.

Operators

In the most simplistic form, eq[<field>]=<value> in the query translates to an equals filter, for example name=foo translates to a {name: 'foo'} query filter specification.

In the previous example the eq operator was used. To use other operators change it to supported operators: gt, gte, lt, lte

Values

Values are auto-detected and converted to an data-type, but would be important to have a way explicitly specified in the field spec.

If multiple values are given for the same field, the value is considered an array, regardless of the operator type.

Special Parameters

offset

Specifies the offset into the documents list.

limit

Specifies the number of documents to limit the result.

sort

Field to sort the result on. By default, the sort is in an ascending order.

Examples

Basic search

Search with operators

Sorting results

Pagination

Testing

This steps are necessary to execute the test suite:

$ cd github_api
$ rspec

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.