Wiki

Clone wiki

my.karma.red / Karma P2P Public API Manual

Karma P2P Public API Manual

In order to start working with Karma API you should use Insomnia software. https://insomnia.rest/

Karma API file can be downloaded here

Allowed HTTPs requests: POST

How do upload API file to Insomnia:

  • Press arrow in 'My Workspace' menu and choose 'Import/Export'

Screen Shot 2018-08-19 at 00.25.14.png

  • Proceed to 'Data' tab - Import Data - From File

Screen Shot 2018-08-19 at 00.28.00.png

  • Locate your «Karma_API_v.2.0.json» file and press 'ОК''

“Karma_API_v.2.0.json” file contains all the currently used APIs by Karma 2.0

2018-10-11_14-39-18.png

New Request

1.Press “+” sign to add New Request

2018-10-11_14-42-25.png

2.Choose HTTPs requests: POST and Structure: GraphQL Query

Screen Shot 2018-08-19 at 00.38.39.png

3.Use URL https://devnet-my.karma.red/graphql

Screen Shot 2018-08-19 at 00.39.43.png

4.Authorisation with Bearer Token

Go to 'Auth' tab and choose 'Bearer Token'

Screen Shot 2018-08-19 at 00.40.47.png

5.Get the Bearer Token using “Login with Email and Password” method

6.Insert result in the 'Token' filed

Screen Shot 2018-08-19 at 00.42.10.png

Description Of Usual Server Responses

  1. 200 OK - the request was successful

  2. 400 Bad Request - the request could not be understood or was missing required parameters

  3. 500 Internet Server Error - Something went wrong (see the description)

API Description

1. User Operation

Description of used methods: user creation, password setup, password recovery and etc. 


Mutation Api Expected result Comments
Creation new user mutation m{registerUser( input:{ email:"sample@gmail.com"}) {status} } "status": true Send mail with authentication link / token in email
Login with token mutation m {loginWithAuthenticationToken( input:{ token:"jhcfcK"}) {token} } “token”: “__” Get bearer token Enter token value from a received email my.karma.red/token/<token_value>
Set pass mutation m {setViewerPassword( input: { password: "_"}) {viewer { shouldProvidePassword}} } "shouldProvidePassword": false Set password. Minimum length is 8 symbols
Reset Pass mutation m {resetPassword( input: { email:"sample@gmail.com"}) {status} } Send mail with authentication link / token in email "status": true After receiving token go to step "Login with token”
Authentication with email and pass mutation m {loginWithEmailAndPasswor( input: { email:"sample@gmail.com" password: «_»}) {token} } Get new Bearer Token for authorisation Login with your Bearer Token (see above)

2. Profiles

2.1 Legal entity's and natural person's profile creation

In order to execute below methods, please, login with your bearer token from method 'Login with email and Password'.

Mutation Api Expected result Comments
Create Individual profile mutation m {createIndividualProfile( input:{ name: "_",signedPhone: "__"}) profile {id, name}}} "profile": { "id": , "name": : Natural person's profile creation. Allocation ID to a profile
Update Individual profile mutation m {updateIndividualProfile ( input:{ id: "", name: "" signedPhone: "", signedAvatar: ””}) {profile{ id, name }}} Getting changed fields in a profile "profile": 1. id: ID (profile) value from query "Query Profile” 2. signedPhone : received value from mutation "Confirm Phone” (see below) 3. signedAvatar: received value from mutation “Avatar” (see below)
Query Profile query q { viewer { id, emai, profiles{ id ... on IndividualProfile{name}}}} viewer { ‘id’: , ‘email’:, profiles { id’: , ‘name’: }} Use LegalEntityProfile, if you have legal profile or IndividualProfile, if you have individual profile
Сreate Legal Entity Profile mutation m {createLegalEntityProfile( input: { inn: "", name: ""}) {profile {id, inn, name}}} "profile": { ‘Id’: , ‘inn’:, "name": Legal Entity's Individual Taxpayer Identification Number (ITIN). Minimum length is 10 symbols
Update Legal Entity Profile mutation m { updateIndividualProfile ( input:{ id: '', name: "", inn:"" , phone: "+7" , signedAvatar: "_" }) {profile{ id, name, inn}}} "profile": 1. phone number currently available only for Rus number. 2. signedAvatar receive value from mutation "Avatar"(see below)

2.2 Phone number

Phone number verification

Mutation Api Expected result Comments
Mutation Api Expected result Comments
Request Phone Confirmation mutation m {requestPhoneConfirmation ( input:{ phone: "+7___"}) {status} } Receiving SMS with confirmation number "status": true phone: put here your phone number (currently available only for Russian numbers starting with '+7' code)
Confirm phone mutation m {confirmPhone ( input:{ phone: ‘+7___’ , token:"_"}) {signedPhone} } “confirmPhone": token: put here received token from SMS

2.3 Upload File / Upload Avatar

2.3.1 Upload File

Upload your file by choosing 'Multipart Form' in Insomnia interface

2018-10-12_20-22-56.png

Enter ‘Upload File' mutation in the query field and than upload File in ‘file' field.

![2018-10-12_20-23-13.png](https://bitbucket.org/repo/4pj8odq/images/...)

Mutation Api Expected result Comments
Upload File mutation m { uploadFile( input: {field: "file"}) {id, url}} "id": "E8Is7BNV1", “url": "https://devnet-my.karma.red/cdn/attachments/rydmz9Opf/E8Is7BNV1/...", "size": 179943, "width": 1228, "height": 772, "format": "png", "filename": "assert.png" If a picture was uploaded fields 'format',’width’, ’height’ are not ‘null’. Otherwise they are.”

2.3.2 Upload Avatar

Upload your avatar by choosing 'Multipart Form' in Insomnia interface

2018-10-12_22-20-31.png

Mutation Api Expected result Comments
Upload Avatar mutation m {uploadAvatar( input: { field: "avatar"}) {url, signedAvatar}} "uploadAvatar": { "url": "https://devnet-my.karma.red/cdn/uploads/...", "signedAvatar": “eyJhbGc…..”

2.4 Accreditation

Process of profile verification with phone number and accreditation request.

Mutation Api Expected result Comments
Query profiles and wallet query q { viewer { id email profiles{id wallet { id name} ... on IndividualProfile{ name}}}} Profile and wallet info use LegalEntityProfile, if you have legal profile or IndividualProfile, if you have individual profile
Update Individual Profile Investor Accreditation mutation m { updateIndividualProfileInvestorAccreditation(input: { profileId: "" , name: "" , inn: "" , iian: "" , birthDate: "" , birthPlace: "" , employment: "" , isPublicOfficial: false/true registrationAddress: { country: "" , region: "" , area: "" , locality: "" , street: "" , house: "" , housing: "" , structure: "" , flat: "" ,} actualAddress: { country: "" , region: "" , area: "" , locality: "" , street: "" , house: "" , housing: "" , structure: "" , flat: "" } passport: { series: "" , number: "" , issuedAt: "" , issuedBy: { code: "" , name: "" ,} scans: [ "" , "" ]} bankAccount: { bank: { bic: "" , name:"" } checkingAccount: "" , correspondentAccount: "" }}) {profile{id, name, phone, wallet{id, name, karma}}}} Profile and wallet info Fill in the fields
Update Legal Entity Profile Borrower Data mutation m { updateLegalEntityProfileBorrowerData( input: { profileId: "" , inn: "" , ogrn: "" , name: "" , iian: "" , address: { country: "" , region: "" , area: "" , locality: "" , street: "" , house: "" , housing: "" , structure: "" , flat: "" } business: { main: "" , aux: "" , legalForm: "" , startedAt: "" } executive:{ name: "" } actualAddress: { country: "" , region: "" , area: "" , locality: "" , street: "" , house: "" , housing: "" , structure: "" , flat: "" } bankAccounts: { bank:{ bic: "" , name: ""} checkingAccount: "" , correspondentAccount: "" } isDraft: true/false}) Profile and wallet info Fill in the fields
Request Profile Phone Confirmation mutation m { requestProfilePhoneConfirmation( input:{ profileId: "_" }) {status}} Receiving SMS with confirmation number "status": true profileId: Put here id (profile) value from query 'Profiles and wallet query'
Request Accreditation mutation m { requestProfileAccreditation( input:{ role: INVESTOR /BORROWER token: "" , profileId: ""})} 1. role: You can choose role INVESTOR or BORROWER 2. token: Put here received token from SMS 3. profileId: Put here id (profile) value from query 'Profiles and wallet query'

3. Loan order

Creating Loan Order.

Data put on https://devnet-my.karma.red/ forms a json string which forms an Order which consists of

Application and an Offer

Order is verified via sms and then proceeds to moderation stage.

Mutation Api Expected result Comments
Create Order mutation m { createOrder( input: { profileId: "__"}) {order {id…}} "order": This method forms an Order
Update Order Application mutation m { updateOrderApplication( input: { orderId: “T3JkZXI6MUR5bzByUE5X", application: "" , attachments:["", "_"] isDraft: false/true}) {order { id…}} "order": Order's Application creation. 'Application' field is also a json string of data put from the front office
Update Order Offer mutation m { updateOrderOffer( input: { orderId: "T3JkZXI6MUR5bzByUE5X", data: "" , attachments:["" , "_" ]}) {order { id…}} "order": Order's Offer creation. 'Data' field is also a json string of data put from the front office
Request Profile Phone Confirmation mutation m { requestProfilePhoneConfirmation( input:{ profileId: "__"}) {status}} Receiving SMS with confirmation number status": true This mutation requests confirmation on order being processed to moderation stage via sms.
Request Order Approval mutation m { requestOrderApproval( input:{ token:"" , orderId:"" }) {order { id }}} "order": Approval of forms moderation transition

4. Investment

Mutation creates a database entry that a user is going to invest into a loan

Mutation Api Expected result Comments
Сreate Investment mutation m { createInvestmentIntent( input: { orderId: “__" profileId: "_"}) {status}} Receiving SMS with confirmation number "status": true orderID' - Loan Order ID 'profileID' - Investor's profile Id
Query orderId query q { orders( first: 10) { count edges { node { id name}}}}} "orders": { {"node": { "id": "T3JkZXI6TFJiRkVqT3ZX", "profile": { "id": "name": "ОАО \"Аленка Капитал\"" "orderId' - Order identification query
Query profileId query q { viewer { id email profiles{id}} "profiles": [ {"id": “TGVnYWxFbnRpdHlQcm9maWxlOkxtUjZmbnU0Qg”}} “profileID - Investor's identification query

Updated