Skip to content

Commit

Permalink
[feat] Add .http files for API call references (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 authored Apr 17, 2024
1 parent 4f12b33 commit ad8b28b
Show file tree
Hide file tree
Showing 27 changed files with 1,471 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This repository holds hundreds of code examples for using the EasyPost API acros
- `fixtures` holds all of the test data used as fixtures in our client library test suites
- `guides` holds all the code snippets that populate on our guides page. Each language will have its own subdirectory
- `responses` holds all of the associated responses for our example snippets found in the `docs` directory that will give you a good idea of what to expect back from the EasyPost API
- `community` holds code snippets contributed from the community. These may include custom workflows, how to integrate EasyPost with other software, etc
- `community` holds code snippets contributed from the community. These may include custom workflows, how to integrate EasyPost with other software, etc. These are **unofficial** and **not supported or maintained by EasyPost**.

## Usage

Expand Down
5 changes: 5 additions & 0 deletions community/docs/http_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
These are `.http` files representing examples of HTTP requests that can be made to the API.

They can be run using the [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension
in Visual Studio Code or the [HTTP Client](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html)
in JetBrains IDEs. They can also be exported as cURL commands.
100 changes: 100 additions & 0 deletions community/docs/http_files/addresses.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@API_KEY = EASYPOST_API_KEY

# Create an Address
POST https://api.easypost.com/v2/addresses
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "417 MONTGOMERY ST",
"street2": "FLOOR 5",
"city": "SAN FRANCISCO",
"state": "CA",
"zip": "94104",
"country": "US",
"company": "EasyPost",
"phone": "415-123-4567"
}
}

###

# Create and verify an Address in one call (basic verification checks)
POST https://api.easypost.com/v2/addresses/create_and_verify
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
}
}

###

# Create and verify an Address in one call (basic + delivery/zip validation)
POST https://api.easypost.com/v2/addresses/create
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
},
"verify": true
}

###

# Create and verify an Address in one call (basic + strict delivery/zip validation)
POST https://api.easypost.com/v2/addresses/create
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
},
"verify_strict": true
}

###

# Verify an existing Address (basic verification checks)
GET https://api.easypost.com/v2/addresses/{{ADDRESS_ID}}/verify
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Retrieve an Address
GET https://api.easypost.com/v2/addresses/{{ADDRESS_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# List all Addresses
GET https://api.easypost.com/v2/addresses
?page_size=10
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
49 changes: 49 additions & 0 deletions community/docs/http_files/api-keys.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@API_KEY = EASYPOST_API_KEY

# Create a test API key
POST https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"mode": "test"
}

###

# Create a production API key
POST https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"mode": "production"
}

###

# Retrieve all API keys
GET https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Enable a disabled API key
POST https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}/enable
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Disable an enabled API key
POST https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}/disable
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an API key
DELETE https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
89 changes: 89 additions & 0 deletions community/docs/http_files/batches.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@API_KEY = EASYPOST_API_KEY

# Create a Batch with existing Shipments
POST https://api.easypost.com/v2/batches
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"batch": {
"shipments": [
{
"id": "shp_123"
},
{
"id": "shp_456"
}
]
}
}

###

# Add Shipments to a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/add_shipments
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"shipments": [
{
"id": "shp_789"
}
]
}

###

# Remove Shipments from a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/remove_shipments
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"shipments": [
{
"id": "shp_789"
}
]
}

###

# Purchase a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/buy
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Generate a label for a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/label
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"file_format": "PDF"
}

###

# Generate a ScanForm for a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/scan_form
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Retrieve a Batch
GET https://api.easypost.com/v2/batches/{{BATCH_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# List all Batches
GET https://api.easypost.com/v2/batches
?page_size=5
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
61 changes: 61 additions & 0 deletions community/docs/http_files/billing.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@PARTNER_API_KEY = PARTNER_API_KEY
@REFERRAL_CUSTOMER_API_KEY = REFERRAL_CUSTOMER_API_KEY
@API_KEY = EASYPOST_API_KEY

# Get EasyPost public key for authenticating with Stripe
GET https://api.easypost.com/v2/partners/stripe_public_key
Authorization: Bearer {{PARTNER_API_KEY}}
Content-Type: application/json

###

# Add a Stripe credit card to referral customer's account
POST https://api.easypost.com/v2/credit_cards
Authorization: Bearer {{REFERRAL_CUSTOMER_API_KEY}}
Content-Type: application/json

{
"credit_card": {
"stripe_object_id": "tok_...",
"priority": "primary"
}
}

###

# List account payment methods
GET https://api.easypost.com/v2/payment_methods
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Fund account with on-file credit card ($10.00)
POST https://api.easypost.com/v2/credit_cards/{{CREDIT_CARD_ID}}/charges
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"amount": 1000
}

###

# Fund account with on-file bank account ($10.00)
POST https://api.easypost.com/v2/bank_accounts/{{BANK_ACCOUNT_ID}}/charges
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an on-file credit card from account
DELETE https://api.easypost.com/v2/credit_cards/{{CREDIT_CARD_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an on-file bank account from account
DELETE https://api.easypost.com/v2/bank_accounts/{{BANK_ACCOUNT_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
18 changes: 18 additions & 0 deletions community/docs/http_files/brands.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@API_KEY = EASYPOST_API_KEY

# Update a user's brand
PATCH https://api.easypost.com/v2/users/{{USER_ID}}/brand
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"brand": {
"background_color": "#FFFFFF",
"color": "#303F9F",
"logo": "data:image/png;base64,iVBORw0K...",
"logo_href": "https://easypost.com",
"ad": "null",
"ad_href": "null",
"theme": "theme1"
}
}
Loading

0 comments on commit ad8b28b

Please sign in to comment.