Skip to content

Latest commit

 

History

History
145 lines (111 loc) · 4.78 KB

README.md

File metadata and controls

145 lines (111 loc) · 4.78 KB

Go Forth 'n Prosper (gofn-prosper)

Build Status Coverage Status GoDoc Go Report Card

Overview

Go Forth 'n Prosper is a set of API Bindings for the Prosper Peer to Peer Lending API.

Currently, about 80% of the functionality is implemented.

Example Usage

For an example of a project that uses gofn-prosper, see:

  • ProsperBot - An automated note buyer and account tracker.

API Documentation

The sections below give a high-level overview of some gofn-propser features. For full details, refer to the gofn-prosper GoDoc.

Creating a Client

All Prosper actions take place through a Client interface. To create a Client instance, do the following:

import (
  "github.com/mtlynch/gofn-prosper/prosper"
  "github.com/mtlynch/gofn-prosper/prosper/auth"
)

client := prosper.NewClient(auth.ClientCredentials{
  ClientID:     "your client ID",
  ClientSecret: "your client secret",
  Username:     "your Prosper username",
  Password:     "your Prosper password",
  })

ClientID and ClientSecret are the values Prosper assigns to you when you generate OAuth credentials on the OAuth Settings page.

Note: If it seems strange to you that you need to enter your OAuth credentials and your username/password, it is strange, but this is a requirement of the Prosper API.

Account Information

The Account API allows clients to retrieve information about their account, such as available balance and account value:

account, err := client.Account(prosper.AccountParams{})
if err != nil {
  fmt.Printf("Failed to retrieve account information: %v", err)
  return
}
fmt.Printf("Your account has $%.2f in cash and a total value of $%.2f\n",
  account.AvailableCashBalance, account.TotalAccountValue)
Your account has $250.00 in cash and a total value of $1893.91

Searching Available Notes

The Search API allows clients to search the available listings, filtering by listing criteria.

This snippet shows how to search for loans with prosper ratings of A or B, where the borrower earns between $50,000 and $75,000 per year:

searchResp, err := client.Search(prosper.SearchParams{
  Offset: 0,
  Limit:  5,
  Filter: prosper.SearchFilter{
    Rating:      []prosper.Rating{prosper.RatingA, prosper.RatingB},
    IncomeRange: []prosper.IncomeRange{prosper.Between50kAnd75k},
  },
})
if err != nil {
  fmt.Printf("Failed to search available note listings: %v\n", err)
  return
}
fmt.Printf("Found %d matching notes, showing first %d\n",
  searchResp.TotalCount, searchResp.ResultCount)
for i, listing := range searchResp.Results {
  fmt.Printf("%2d: ID: %v  Loan Amount: $%5.0f  Yield: %.2f%%\n",
    i+1, listing.ListingNumber, listing.ListingAmount,
    listing.EffectiveYield*100.0)
Found 27 matching notes, showing first 5
 1: ID: 5492410  Loan Amount: $15000  Yield: 9.01%
 2: ID: 5302541  Loan Amount: $14700  Yield: 9.70%
 3: ID: 5515002  Loan Amount: $15500  Yield: 7.99%
 4: ID: 5298533  Loan Amount: $20000  Yield: 6.85%
 5: ID: 5511744  Loan Amount: $ 6000  Yield: 8.58%

Buying a Note

The PlaceBid API allows clients to make a bid on a Prosper listing.

orderResp, err := client.PlaceBid(prosper.BidRequest{
  ListingID: 5492410,
  BidAmount: 25.0,
})
if err != nil {
  fmt.Printf("Failed to place bid: %v\n", err)
  return
}
fmt.Printf("Successfully placed order. Order ID: %v\n", orderResp.OrderID)
Successfully placed order. Order ID: a9d4b52b-34cb-4112-bf57-671a18efecdd

Checking Order Status

orderID := prosper.OrderID("a9d4b52b-34cb-4112-bf57-671a18efecdd")
orderResp, err := client.OrderStatus(orderID)
if err != nil {
  fmt.Printf("Failed to check order status: %v\n", err)
  return
}
if orderResp.OrderStatus == prosper.OrderCompleted {
  fmt.Printf("Order %v is complete\n", orderID)
} else {
  fmt.Printf("Order %v is in progress\n", orderID)
}
Order a9d4b52b-34cb-4112-bf57-671a18efecdd is complete

Relationship to Prosper, Inc.

Go Forth 'n Prosper is not affiliated with Prosper, Inc. It is released as an independently maintained library for interacting with Prosper's public API.

License

Go Forth 'n Propser is released under the Apache 2 License.