mlh-apideprecated

A wrapper for the Major League Hacking (MLH) API.

Usage no npm install needed!

<script type="module">
  import mlhApi from 'https://cdn.skypack.dev/mlh-api';
</script>

README

MLH API

NPM version

A wrapper for the Major League Hacking (MLH) API.

Install

Install with npm:

$ npm i mlh-api --save

Usage

Configuring the module:

const mlh = require('./index')

mlh.configure({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  redirectUri: 'YOUR_REDIRECT_URI'
})

Authorization Code Flow

Redirect your user to this url:

const url = mlh.authorizationCodeUrl(['your', 'scopes', 'here'])

Get the authorization code from the MLH callback to obtain an access token:

mlh.accessTokenFromAuthorizationCode(code).then(() => {
  // Module is now configured with the access token
  // Get user object
  return mlh.user()
}).then(user => {
  // Do stuff with user object
})

Implicit Authorization Flow

Redirect your user to this url:

const url = mlh.implicitAuthorizationUrl(['your', 'scopes', 'here'])

Set the access token from the MLH callback:

mlh.configure({ accessToken: token })

// Make user requests
mlh.users(1, 100).then(users => {
  // Do stuff with users
})

Please visit the module documentation and the MLH API documentation for more information

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Tomer Aberbach

License

Copyright © 2018 Tomer Aberbach Released under the MIT license.