Line REST API documentation

Warning

This is alpha-development version of API and may be the subject to change.

Authentication

For now all API calls are authenticated with HTTP Basic Authentication (username being user email), or using existing session cookie (for GET verb endpoints only).

When 2-factor authentication is enabled for calling account otp query field is required for some calls.

Output formats

Output will be formatted according to provided Accept header. Currently supported formats are:

  • application/json (default) - standard JSON formatting
  • text/csv - CSV output with header row (only available in list resources, eg. transactions and friends list)

Resources

Note

All currency values are represented as integers in lowest denomination (1 satoshi for Bitcoin)

Note

All interest values are represented as 5-digit precision decimals in strings.

Friends

GET /api/v1/friends/

Friends and their data list

Response JSON Array of Objects:
 
  • id (integer) – user ID
  • name (string) – user display name
  • investment (object) – investment information
  • investment.available (integer) – all available loan
  • investment.used (integer) – current used amount
  • investment.limit (integer) – limit set by user
  • investment.interest (string) – interest rate
  • loan (object) – loan information (same as investment)
Status Codes:
PUT /api/v1/friends/(int: friend_id)/

Updates investment values or adds new friend

Query Parameters:
 
  • limit – investment limit
  • interest – interest rate
  • otp – one-time password (when enabled)
Status Codes:
DELETE /api/v1/friends/(int: friend_id)/

Removes selected friend

Status Codes:
GET /api/v1/friends/(int: friend_id)/

Information about specified friend

Response JSON Object:
 
  • id (integer) – user ID
  • name (string) – user display name
  • investment (object) – investment information (look above)
  • loan (object) – loan information (look above)
Status Codes:

Example request:

GET /api/v1/friends/ HTTP/1.1
Accept: application/json, text/javascript
Authorization: Basic dXNlcjp0ZXN0
Host: getline.in

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": 3,
        "investment": {
            "available": 4962777,
            "limit": 5000000,
            "used": 4962777
        },
        "loan": {
            "limit": 0,
            "used": 0
        },
        "name": "John"
    },
    {
        "id": 1,
        "investment": { "[ ... ]" },
        "loan": { "[ ... ]" },
        "name": "Mike"
    }
]

Wallet

GET /api/v1/wallet/

Information about current user wallet

Response JSON Object:
 
  • balance (integer) – user wallet balance
  • address (string) – Bitcoin input address
  • last_transactions (array) – last 10 transactions
GET /api/v1/wallet/transactions/

User transactions list

Response JSON Array of Objects:
 
  • id (integer) – unique transaction ID
  • type (string) – transaction type
  • amount (integer) – transaction amount
  • date (datetime) – transaction date
POST /api/v1/wallet/withdraw/

Withdraws funds from user wallet

Query Parameters:
 
  • amount – withdrawal amount
  • address – target address
Response JSON Object:
 
  • id (integer) – new transaction ID
Status Codes:

Users

GET /api/v1/users/(int: user_id)/

Public user profile

Response JSON Object:
 
  • id (integer) – user ID
  • name (string) – user display name
  • loan_need_description (string) – loan description (markdown-formatted)
  • loan_need_amount (integer) – requested loan amount
  • loan_need_interest (string) – requested loan interest
  • approved (bool) – user approval status
  • days_since_last_payment (integer) – days since last deposit (null when no recorded deposits)
  • loan_sum (integer) – active user loan
Status Codes:
GET /api/v1/users/(int: user_id)/investments/

User investments list

Response JSON Array of Objects:
 
  • id (integer) – user ID
  • name (string) – user display name
  • available (integer) – all available loan
  • used (integer) – current used amount
  • limit (integer) – limit set by investor
  • interest (string) – interest rate
Status Codes:
GET /api/v1/users/(int: user_id)/loans/

User loans list

Response JSON Array of Objects:
 
  • id (integer) – user ID
  • name (string) – user display name
  • available (integer) – all available loan
  • used (integer) – current used amount
  • limit (integer) – limit set by investor
  • interest (string) – interest rate
Status Codes:
GET /api/v1/users/(int: user_id)/comments/

User comments list

Response JSON Array of Objects:
 
  • author.id (integer) – author user ID
  • author.name (string) – author display name
  • date (datetime) – comment creation date
  • content (string) – comment text
Status Codes:

Example client

httpie can be used to test the API:

$ http PUT https://username:password@getline.in/api/v1/friends/3/ limit=1000 interest=0.001

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 38
Content-Type: application/json
Date: Fri, 06 Jan 2017 10:55:16 GMT

{
    "message": "Success",
    "status": 200
}