{"id":29583547,"url":"https://github.com/easypost/easypost-java","last_synced_at":"2025-07-19T23:13:50.205Z","repository":{"id":8878590,"uuid":"10594634","full_name":"EasyPost/easypost-java","owner":"EasyPost","description":"EasyPost Shipping API Client Library for Java","archived":false,"fork":false,"pushed_at":"2025-06-18T16:34:33.000Z","size":14578,"stargazers_count":51,"open_issues_count":0,"forks_count":38,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-07-18T12:46:44.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://easypost.com/docs/api","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EasyPost.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-06-10T06:20:47.000Z","updated_at":"2025-06-18T16:28:30.000Z","dependencies_parsed_at":"2024-08-16T17:35:29.104Z","dependency_job_id":"46d74427-9528-409c-9608-79713fd6b121","html_url":"https://github.com/EasyPost/easypost-java","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/EasyPost/easypost-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyPost","download_url":"https://codeload.github.com/EasyPost/easypost-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266039073,"owners_count":23867824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-19T23:13:48.849Z","updated_at":"2025-07-19T23:13:50.199Z","avatar_url":"https://github.com/EasyPost.png","language":"Java","funding_links":[],"categories":["API\u0026客户端"],"sub_categories":["文件同步"],"readme":"# EasyPost Java Client Library\n\n[![CI](https://github.com/EasyPost/easypost-java/workflows/CI/badge.svg)](https://github.com/EasyPost/easypost-java/actions?query=workflow%3ACI)\n[![Coverage Status](https://coveralls.io/repos/github/EasyPost/easypost-java/badge.svg?branch=master)](https://coveralls.io/github/EasyPost/easypost-java?branch=master)\n[![Maven Central](https://img.shields.io/maven-central/v/com.easypost/easypost-api-client?label=Maven%20Central)](https://central.sonatype.dev/search?q=easypost-api-client)\n\nEasyPost, the simple shipping solution. You can sign up for an account at \u003chttps://easypost.com\u003e.\n\n## Install\n\n### Maven\n\nAdd this to your project's POM:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.easypost\u003c/groupId\u003e\n  \u003cartifactId\u003eeasypost-api-client\u003c/artifactId\u003e\n  \u003cversion\u003e8.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\nAdd this to your project's build file:\n\n```groovy\nimplementation \"com.easypost:easypost-api-client:8.2.0\"\n```\n\n**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.\n\n## Usage\n\nA simple create \u0026 buy shipment example:\n\n```java\npackage shipments;\n\nimport com.easypost.EasyPost;\nimport com.easypost.exception.EasyPostException;\nimport com.easypost.model.Shipment;\nimport com.easypost.service.EasyPostClient;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\npublic class CreateShipment {\n  public static void main(String[] args) throws EasyPostException {\n    EasyPostClient client = new EasyPostClient(System.getenv(\"EASYPOST_API_KEY\"));\n\n    Map\u003cString, Object\u003e fromAddressMap = new HashMap\u003cString, Object\u003e();\n    fromAddressMap.put(\"company\", \"EasyPost\");\n    fromAddressMap.put(\"street1\", \"417 MONTGOMERY ST\");\n    fromAddressMap.put(\"street2\", \"FLOOR 5\");\n    fromAddressMap.put(\"city\", \"SAN FRANCISCO\");\n    fromAddressMap.put(\"state\", \"CA\");\n    fromAddressMap.put(\"country\", \"US\");\n    fromAddressMap.put(\"zip\", \"94104\");\n    fromAddressMap.put(\"phone\", \"415-123-4567\");\n\n    Map\u003cString, Object\u003e toAddressMap = new HashMap\u003cString, Object\u003e();\n    toAddressMap.put(\"name\", \"Dr. Steve Brule\");\n    toAddressMap.put(\"street1\", \"179 N Harbor Dr\");\n    toAddressMap.put(\"city\", \"Redondo Beach\");\n    toAddressMap.put(\"state\", \"CA\");\n    toAddressMap.put(\"country\", \"US\");\n    toAddressMap.put(\"zip\", \"90277\");\n    toAddressMap.put(\"phone\", \"310-808-5243\");\n\n    Map\u003cString, Object\u003e parcelMap = new HashMap\u003cString, Object\u003e();\n    parcelMap.put(\"weight\", 22.9);\n    parcelMap.put(\"height\", 12.1);\n    parcelMap.put(\"width\", 8);\n    parcelMap.put(\"length\", 19.8);\n\n    Map\u003cString, Object\u003e shipmentMap = new HashMap\u003cString, Object\u003e();\n    shipmentMap.put(\"from_address\", fromAddressMap);\n    shipmentMap.put(\"to_address\", toAddressMap);\n    shipmentMap.put(\"parcel\", parcelMap);\n\n    Shipment shipment = client.shipment.create(shipmentMap);\n\n    Shipment boughtShipment = client.shipment.buy(shipment.getId(), shipment.lowestRate());\n\n    System.out.println(boughtShipment.prettyPrint());\n  }\n}\n```\n\n## HTTP Hooks\n\nUsers can subscribe to HTTP requests and responses via the `RequestHook` and `ResponseHook` objects. To do so, pass a function to the `subscribeToRequestHook` or `subscribeToResponseHook` methods of an `EasyPostClient` object:\n\n```java\n    EasyPostClient client = new EasyPostClient(System.getenv(\"EASYPOST_API_KEY\"));\n\n    // For request hook custom function, make sure you have RequestHookResponses in the parameter\n    public static Object requestHookFunction(RequestHookResponses data) {\n        // Pass your code here, the information about the request/response is available within the data parameter.\n        return true;\n    }\n\n    client.subscribeToRequestHook(requestHookFunction); // subscribe to request hook by passing your custom function\n    client.unsubscribeToRequestHook(requestHookFunction); // unsubscribe from request hook\n\n    // For response hook custom function, make sure you have ResponseHookResponses in the parameter\n    public static Object responseHookFunction(ResponseHookResponses data) {\n        // Pass your code here, the information about the request/response is available within the data parameter.\n        return true;\n    }\n\n    client.subscribeToResponseHook(responseHookFunction); // subscribe to response hook by passing your custom function\n    client.unsubscribeToResponseHook(responseHookFunction); // unsubscribe from response hook\n```\n\n## Documentation\n\nAPI documentation can be found at: \u003chttps://docs.easypost.com\u003e.\n\nLibrary documentation can be found on the web at: \u003chttps://easypost.github.io/easypost-java/\u003e or by building them locally via the `make docs` command.\n\nUpgrading major versions of this project? Refer to the [Upgrade Guide](UPGRADE_GUIDE.md).\n\n## Support\n\nNew features and bug fixes are released on the latest major release of this library. If you are on an older major release of this library, we recommend upgrading to the most recent release to take advantage of new features, bug fixes, and security patches. Older versions of this library will continue to work and be available as long as the API version they are tied to remains active; however, they will not receive updates and are considered EOL.\n\nFor additional support, see our [org-wide support policy](https://github.com/EasyPost/.github/blob/main/SUPPORT.md).\n\n## Development\n\n### Tests\n\n```bash\n# Install dependencies\nmake install\n\n# Build project\nmake build\n\n# Lint project\nmake lint\n\n# Run tests\nEASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make build test\nEASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage\n\n# Run security analysis\nmake scan\n\n# Generate library documentation\nmake docs\n\n# Update submodules\nmake update-examples-submodule\n```\n\n### Testing\n\nThe test suite in this project was specifically built to produce consistent results on every run, regardless of when they run or who is running them.\n\nThis project uses [EasyVCR](https://github.com/EasyPost/easyvcr-java) to record and replay HTTP requests and responses via \"cassettes\". When the suite is run, the HTTP requests and responses for each test function will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which saves the need to make live API calls on every test run.\n\n**Sensitive Data:** We've made every attempt to include scrubbers for sensitive data when recording cassettes so that PII or sensitive info does not persist in version control; however, please ensure when recording or re-recording cassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the cassette.\n\n**Making Changes:** If you make an addition to this project, the request/response will get recorded automatically for you. When making changes to this project, you'll need to re-record the associated cassette to force a new live API call for that test which will then record the request/response used on the next run.\n\n**Test Data:** The test suite has been populated with various helpful fixtures that are available for use, each completely independent from a particular user **with the exception of the USPS carrier account ID** (see [Unit Test API Keys](#unit-test-api-keys) for more information) which has a fallback value of our internal testing user's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).\n\n#### Unit Test API Keys\n\nThe following are required on every test run:\n\n- `EASYPOST_TEST_API_KEY`\n- `EASYPOST_PROD_API_KEY`\n\nSome tests may require an EasyPost user with a particular set of enabled features such as a `Partner` user when creating referrals. We have attempted to call out these functions in their respective docstrings. The following are required when you need to re-record cassettes for applicable tests:\n\n- `USPS_CARRIER_ACCOUNT_ID` (eg: one-call buying a shipment for non-EasyPost employees)\n- `PARTNER_USER_PROD_API_KEY` (eg: creating a referral user)\n- `REFERRAL_CUSTOMER_PROD_API_KEY` (eg: adding a credit card to a referral user)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasypost%2Feasypost-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasypost%2Feasypost-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasypost%2Feasypost-java/lists"}