Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MarwanRefaat/7583fe32e3694b7ada928ec03fcb468b to your computer and use it in GitHub Desktop.
Save MarwanRefaat/7583fe32e3694b7ada928ec03fcb468b to your computer and use it in GitHub Desktop.
Plaid Transactions JSON Schema to TypeScript
JSON SCHEMA:
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/Welcome",
"definitions": {
"Welcome": {
"type": "object",
"additionalProperties": false,
"properties": {
"accounts": {
"type": "array",
"items": {
"$ref": "#/definitions/Account"
}
},
"transactions": {
"type": "array",
"items": {
"$ref": "#/definitions/Transaction"
}
},
"item": {
"$ref": "#/definitions/Item"
},
"total_transactions": {
"type": "integer"
},
"request_id": {
"type": "string"
}
},
"required": [
"accounts",
"item",
"request_id",
"total_transactions",
"transactions"
],
"title": "Welcome"
},
"Account": {
"type": "object",
"additionalProperties": false,
"properties": {
"account_id": {
"type": "string"
},
"balances": {
"$ref": "#/definitions/Balances"
},
"mask": {
"type": "string"
},
"name": {
"type": "string"
},
"official_name": {
"type": "string"
},
"subtype": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"account_id",
"balances",
"mask",
"name",
"official_name",
"subtype",
"type"
],
"title": "Account"
},
"Balances": {
"type": "object",
"additionalProperties": false,
"properties": {
"available": {
"type": "integer"
},
"current": {
"type": "integer"
},
"iso_currency_code": {
"type": "string"
},
"limit": {
"type": "null"
},
"unofficial_currency_code": {
"type": "null"
}
},
"required": [
"available",
"current",
"iso_currency_code",
"limit",
"unofficial_currency_code"
],
"title": "Balances"
},
"Item": {
"type": "object",
"additionalProperties": false,
"properties": {
"available_products": {
"type": "array",
"items": {
"type": "string"
}
},
"billed_products": {
"type": "array",
"items": {
"type": "string"
}
},
"consent_expiration_time": {
"type": "null"
},
"error": {
"type": "null"
},
"institution_id": {
"type": "string"
},
"item_id": {
"type": "string"
},
"update_type": {
"type": "string"
},
"webhook": {
"type": "string",
"format": "uri",
"qt-uri-protocols": [
"https"
]
}
},
"required": [
"available_products",
"billed_products",
"consent_expiration_time",
"error",
"institution_id",
"item_id",
"update_type",
"webhook"
],
"title": "Item"
},
"Transaction": {
"type": "object",
"additionalProperties": false,
"properties": {
"account_id": {
"type": "string"
},
"amount": {
"type": "number"
},
"iso_currency_code": {
"type": "string"
},
"unofficial_currency_code": {
"type": "null"
},
"category": {
"type": "array",
"items": {
"type": "string"
}
},
"category_id": {
"type": "string",
"format": "integer"
},
"check_number": {
"type": "null"
},
"date": {
"type": "string",
"format": "date"
},
"datetime": {
"type": "string",
"format": "date-time"
},
"authorized_date": {
"type": "string",
"format": "date"
},
"authorized_datetime": {
"type": "string",
"format": "date-time"
},
"location": {
"$ref": "#/definitions/Location"
},
"name": {
"type": "string"
},
"merchant_name": {
"type": "string"
},
"payment_meta": {
"$ref": "#/definitions/PaymentMeta"
},
"payment_channel": {
"type": "string"
},
"pending": {
"type": "boolean"
},
"pending_transaction_id": {
"type": "null"
},
"account_owner": {
"type": "null"
},
"transaction_id": {
"type": "string"
},
"transaction_code": {
"type": "null"
},
"transaction_type": {
"type": "string"
}
},
"required": [
"account_id",
"account_owner",
"amount",
"authorized_date",
"authorized_datetime",
"category",
"category_id",
"check_number",
"date",
"datetime",
"iso_currency_code",
"location",
"merchant_name",
"name",
"payment_channel",
"payment_meta",
"pending",
"pending_transaction_id",
"transaction_code",
"transaction_id",
"transaction_type",
"unofficial_currency_code"
],
"title": "Transaction"
},
"Location": {
"type": "object",
"additionalProperties": false,
"properties": {
"address": {
"type": "string"
},
"city": {
"type": "string"
},
"region": {
"type": "string"
},
"postal_code": {
"type": "string",
"format": "integer"
},
"country": {
"type": "string"
},
"lat": {
"type": "number"
},
"lon": {
"type": "number"
},
"store_number": {
"type": "string",
"format": "integer"
}
},
"required": [
"address",
"city",
"country",
"lat",
"lon",
"postal_code",
"region",
"store_number"
],
"title": "Location"
},
"PaymentMeta": {
"type": "object",
"additionalProperties": false,
"properties": {
"by_order_of": {
"type": "null"
},
"payee": {
"type": "null"
},
"payer": {
"type": "null"
},
"payment_method": {
"type": "null"
},
"payment_processor": {
"type": "null"
},
"ppd_id": {
"type": "null"
},
"reason": {
"type": "null"
},
"reference_number": {
"type": "null"
}
},
"required": [
"by_order_of",
"payee",
"payer",
"payment_method",
"payment_processor",
"ppd_id",
"reason",
"reference_number"
],
"title": "PaymentMeta"
}
}
}
TypeScript:
export interface PlaidTransactions {
accounts: Account[];
item: Item;
requestID: string;
totalTransactions: number;
transactions: Transaction[];
}
export interface Account {
accountID: string;
balances: Balances;
mask: string;
name: string;
officialName: string;
subtype: string;
type: string;
}
export interface Balances {
available: number;
current: number;
isoCurrencyCode: string;
limit: null;
unofficialCurrencyCode: null;
}
export interface Item {
availableProducts: string[];
billedProducts: string[];
consentExpirationTime: null;
error: null;
institutionID: string;
itemID: string;
updateType: string;
webhook: string;
}
export interface Transaction {
accountID: string;
accountOwner: null;
amount: number;
authorizedDate: Date;
authorizedDatetime: Date;
category: string[];
categoryID: string;
checkNumber: null;
date: Date;
datetime: Date;
isoCurrencyCode: string;
location: Location;
merchantName: string;
name: string;
paymentChannel: string;
paymentMeta: PaymentMeta;
pending: boolean;
pendingTransactionID: null;
transactionCode: null;
transactionID: string;
transactionType: string;
unofficialCurrencyCode: null;
}
export interface Location {
address: string;
city: string;
country: string;
lat: number;
lon: number;
postalCode: string;
region: string;
storeNumber: string;
}
export interface PaymentMeta {
byOrderOf: null;
payee: null;
payer: null;
paymentMethod: null;
paymentProcessor: null;
ppdID: null;
reason: null;
referenceNumber: null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment