Income Finder

Using the Abound Income API, you can automatically determine the type of income your users are requesting.

Determining The Type of Income

If you haven't done so already, follow the Creating a User guide and ensure you have the resulting userId available for the next step.

Next, add a new expense by calling the POST /users/{userId}/incomes API endpoint. When requesting the income, for an incomeType prediction you must include a description. This ensures that our system for predicting the incomeType has a foundation to work on.

curl \
  --request POST \
  --url https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes \
  --header 'Authorization: Bearer <<apiKey>>' \
  --header 'Content-Type: application/json' \
  --data '{
    "incomes": [
      {
        "amount": 222.34,
        "date": "2020-01-14",
        "description": "Client Invoice",
        "category": "Design Services",
        "foreignId": "your_foreign_id",
        "notes": {}
      }
    ]
  }'
const { default: Abound, Environment } = require("@withabound/node-sdk");

const abound = new Abound({
  appId: "<<sandbox_app_id>>",
  appSecret: "<<sandbox_app_secret>>",
  environment: Environment.SANDBOX,
  apiVersion: "v2",
});

(async () => {
  const response = await abound.incomes.create(
    "<<testUserId>>",
    [
      {
        amount: 222.34,
        date: "2020-01-14",
        description: "Client Invoice",
        category: "Design Services",
        foreignId: "your_foreign_id",
        notes: {},
      },
    ]
  );

  console.log(response);
})();
import requests

url = "https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes"

payload = {"incomes": [
        {
            "amount": 222.34,
            "date": "2020-01-14",
            "description": "Client Invoice",
            "category": "Design Services",
            "foreignId": "your_foreign_id",
            "notes": {}
        }
    ]}
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "Bearer <<apiKey>>"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
// import com.squareup.okhttp.*;
// import com.google.gson.JsonObject;
// import com.google.gson.JsonArray;

OkHttpClient client = new OkHttpClient();

JsonObject requestBody = new JsonObject();
JsonArray incomes = new JsonArray();
JsonObject incomeOne = new JsonObject();
JsonObject incomeOneNotes = new JsonObject();

incomeOne.addProperty("amount", 222.34);
incomeOne.addProperty("date", "2020-01-14");
incomeOne.addProperty("description", "Client Invoice");
incomeOne.addProperty("category", "designServices");
incomeOne.addProperty("foreignId", "your_foreign_id");
incomeOne.add("notes", incomeOneNotes);

incomes.add(incomeOne);

requestBody.add("incomes", incomes);

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, requestBody.toString());
Request request = new Request.Builder()
  .url("https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes")
  .post(body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer <<apiKey>>")
  .build();

Response response = client.newCall(request).execute();
package main

import (
    "bytes"
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes"

    var requestBody = []byte(`{
        "incomes": [
            {
                "amount": 222.34,
                "date": "2020-01-14",
                "description": "Client Invoice",
                "category": "Design Services",
                "foreignId": "your_foreign_id",
                "notes": {}
            }
        ]
    }`)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))

    req.Header.Add("Accept", "application/json")
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer <<apiKey>>")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
// using RestSharp;

var client = new RestClient("https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer <<apiKey>>");
request.AddJsonBody(new {
  incomes = new[] {
    new {
      amount = 222.34,
      date = "2020-01-14",
      description = "Client Invoice",
      category = "Design Services",
      foreignId = "your_foreign_id",
      notes = new {}
    }
  }
});
IRestResponse response = client.Execute(request);
require 'uri'
require 'net/http'
require 'openssl'
require 'json'

url = URI("https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes")
requestBody = {
  incomes: [
    {
      amount: 222.34,
      date: '2020-01-14',
      description: 'Client Invoice',
      category: 'Design Services',
      foreignId: 'your_foreign_id',
      notes: {}
    }
  ]
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer <<apiKey>>'
request.body = requestBody.to_json

response = http.request(request)
puts response.read_body
{
  "data": [
    {
      "incomeId": "incomeId_test8cb0d56b942722b6d719fa5aa9c5a8dbaa0f",
      "incomeType": "1099",
      "amount": 222.34,
      "description": "Client Invoice",
      "date": "2020-01-14",
      "category": "Design Services",
      "notes": {},
      "foreignId": "your_foreign_id",
      "predictions": {
        "incomeTypePredictionScores": {
          "1099": 0.95701,
          "personal": 0.04299,
          "w2": 0
        }
      }
    }
  ],
  "request": {
    "timestamp": 1629924095695,
    "requestId": "requestId_ba1b709c12dd9c62f532dafa"
  }
}

Did this page help you?