api

Your friendly interface to pokey projects.

PokeyAPI is my own attempt at creating a RESTful interface for interacting with my development projects.  SSL is required, and user registration, authentication, and IP address restrictions are strictly enforced.

https://github.com/wnormandin/pokeyapi

Most access routes will require authentication, which requires registration.  Registration requests can be sent to https://api.pokeybill.us/users with POST data containing a username, password, and email.

Once registered, a user can send a POST request to the login URL to obtain an API token, which can be used to authenticate requests for other areas.  Login at https://api.pokeybill.us/login 

API Tokens

API tokens are issued for 24 hour periods at the current stage of development, and are valid only for requests originating from the same IP address as the user login request which generates the token.

API Functions

A list of available functions with examples
  • / – general instructions
    $ curl https://api.pokeybill.us
    {
     "api": "PokeyDev Entry Point - pokeybill.us/api", 
     "details": {
     "email": "validation is required before API usage", 
     "login": "POST {username,password} to /login, returns a token", 
     "tokens": "authentication tokens are required as POST {api_token}", 
     "user details": "POST {api_token} to /users/USERNAME", 
     "user registration": "POST {username,password,email} to /users"
     }, 
     "login": "/login", 
     "usage": "/usage", 
     "users": "/users"
    }
  • /usage – usage base destination
    $ curl https://api.pokeybill.us/usage
    {
      "usage": "Display function-specific usage: /usage/function_name"
    }
  • /usage/function  provides function-specific details
    $ curl https://api.pokeybill.us/usage/api_usage
    {
      "api_usage": " Provides an API usage URL (https://pokeybill.us/api) "
    }
  • /users
    • GET
      $ curl https://api.pokeybill.us/users
      {
        "users": " User authentication, registration, and other requests "
      }
    • POST – User Registration, required details: {username,password,email}
      $ curl -X POST -H 'Content-Type: application/json' -d '{"username":"testuser","password":"123Insecure!","email":"no-reply@pokeybill.us"}' https://api.pokeybill.us/users
      {
       "action": "register",
       "result": true,
       "username": "testuser"
      }
  • /users/username – requires an API token, returns user details
    $ curl -X POST -H 'Content-Type: application/json' -d '{"api_token": "YOUR_TOKEN_HERE"}' https://api.pokeybill.us/users/testuser
    {
      "testuser": {
         "active": true, 
         "created": "Sun, 18 Dec 2016 00:21:58 GMT", 
         "current_login": "Mon, 19 Dec 2016 05:52:09 GMT", 
         "current_login_ipaddr": "192.168.88.23", 
         "email": "no-reply@pokeybill.us", 
         "ipaddr": "192.168.88.23", 
         "last_login": "Sun, 18 Dec 2016 05:59:42 GMT", 
         "modified": "Mon, 19 Dec 2016 05:49:41 GMT", 
         "security_group": "Users", 
         "username": "testuser"
      }, 
      "result": true, 
      "username": "testuser"
    }
  •  /login
    • GET – Login details
      $ curl https://api.pokeybill.us/login
      {
        "login_details": " User login portal - POST credentials for an API token {username,password} "
      }
    • POST – User login, requires credentials: {username,password}
      $ curl -X POST -H 'Content-Type: application/json' -d '{"username":"testuser","password":"123Insecure!"}' https://api.pokeybill.us/login
      {
       "api_token": "$6$rounds=656000$MZ7oMi6SBHa66JDE$CvwfS3ACJBNwC2RUTboCAWetcys4PK7R9/h0BQ4oFpCjdDjATIe0WMjTTC2tSR17IJrflTqNea1R0OUgpSDPm0",
       "last": "Sun, 18 Dec 2016 06:36:06 GMT",
       "result": true,
       "valid_ip": "192.168.22.2"
      }