{"id":29583559,"url":"https://github.com/easypost/easypost-csharp","last_synced_at":"2026-04-03T23:03:09.305Z","repository":{"id":17625496,"uuid":"20429736","full_name":"EasyPost/easypost-csharp","owner":"EasyPost","description":"EasyPost Shipping API Client Library for .NET and .NET Framework applications","archived":false,"fork":false,"pushed_at":"2026-02-20T17:54:16.000Z","size":17889,"stargazers_count":64,"open_issues_count":2,"forks_count":75,"subscribers_count":51,"default_branch":"master","last_synced_at":"2026-02-20T22:12:17.784Z","etag":null,"topics":["client"],"latest_commit_sha":null,"homepage":"https://easypost.com/docs/api","language":"C#","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2014-06-03T04:33:08.000Z","updated_at":"2026-02-20T17:47:46.000Z","dependencies_parsed_at":"2023-10-20T23:30:29.118Z","dependency_job_id":"a0135604-2905-4967-a610-18539eb85d5b","html_url":"https://github.com/EasyPost/easypost-csharp","commit_stats":null,"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"purl":"pkg:github/EasyPost/easypost-csharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyPost","download_url":"https://codeload.github.com/EasyPost/easypost-csharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyPost%2Feasypost-csharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31381009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T21:40:47.592Z","status":"ssl_error","status_checked_at":"2026-04-03T21:40:05.436Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["client"],"created_at":"2025-07-19T23:13:51.819Z","updated_at":"2026-04-03T23:03:09.297Z","avatar_url":"https://github.com/EasyPost.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EasyPost .Net Client Library\n\n[![CI](https://github.com/EasyPost/easypost-csharp/workflows/CI/badge.svg)](https://github.com/EasyPost/easypost-csharp/actions?query=workflow%3ACI)\n[![codecov](https://codecov.io/gh/EasyPost/easypost-csharp/graph/badge.svg?token=y5QUxhFk0o)](https://codecov.io/gh/EasyPost/easypost-csharp)\n[![NuGet version](https://badge.fury.io/nu/EasyPost-Official.svg)](https://badge.fury.io/nu/EasyPost-Official)\n\nEasyPost, the simple shipping solution. You can sign up for an account at \u003chttps://easypost.com\u003e.\n\n## Install\n\n```powershell\nInstall-Package EasyPost-Official\n```\n\nSee NuGet docs for additional instructions on installing via\nthe [dialog](http://docs.nuget.org/docs/start-here/managing-nuget-packages-using-the-dialog) or\nthe [console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console).\n\n## Usage\n\nA simple create \u0026 buy shipment example:\n\n```csharp\nusing System;\nusing System.Threading.Tasks;\nusing EasyPost;\nusing Newtonsoft.Json;\n\nnamespace Example;\n\nclass ExampleClass\n{\n    static async Task Main()\n    {\n        var client = new Client(new ClientConfiguration(Environment.GetEnvironmentVariable(\"EASYPOST_API_KEY\")));\n\n        var createParameters = new EasyPost.Parameters.Shipment.Create()\n        {\n            ToAddress = new EasyPost.Parameters.Address.Create\n            {\n                Name = \"Dr. Steve Brule\",\n                Street1 = \"179 N Harbor Dr\",\n                City = \"Redondo Beach\",\n                State = \"CA\",\n                Zip = \"90277\",\n                Country = \"US\",\n                Phone = \"8573875756\",\n                Email = \"dr_steve_brule@gmail.com\"\n            },\n            FromAddress = new EasyPost.Parameters.Address.Create\n            {\n                Name = \"EasyPost\",\n                Street1 = \"417 Montgomery Street\",\n                Street2 = \"5th Floor\",\n                City = \"San Francisco\",\n                State = \"CA\",\n                Zip = \"94104\",\n                Country = \"US\",\n                Phone = \"4153334445\",\n                Email = \"support@easypost.com\"\n            },\n            Parcel = new EasyPost.Parameters.Parcel.Create\n            {\n                Length = 20.2,\n                Width = 10.9,\n                Height = 5,\n                Weight = 65.9\n            }\n        };\n\n        var shipment = await client.Shipment.Create(createParameters);\n\n        var rate = shipment.LowestRate();\n\n        var buyParameters = new EasyPost.Parameters.Shipment.Buy(rate);\n\n        var purchasedShipment = await client.Shipment.Buy(shipment.Id, buyParameters);\n\n        Console.WriteLine(JsonConvert.SerializeObject(purchasedShipment, Formatting.Indented));\n    }\n}\n```\n\n### Configuration\n\nA `Client` object is the entry point into the EasyPost API. It is instantiated with a `ClientConfiguration` with your API key:\n\n```csharp\nusing EasyPost;\n\nClient myClient = new Client(new ClientConfiguration(\"EASYPOST_API_KEY\"));\n```\n\nAn API key is required for all requests. You can find your API key in\nyour [EasyPost dashboard](https://easypost.com/account/api-keys).\n\nOnce declared, a client's API key cannot be changed. If you are using multiple API keys, you can create multiple client\nobjects.\n\n### Services\n\nAll general API services can be accessed through the `Client` object. For example, to access the `Address` service:\n\n```csharp\nAddressService addressService = myClient.Address;\n```\n\nBeta services can be accessed via the `myClient.Beta` property.\n\n```csharp\nExampleService betaService = myClient.Beta.Example;\n```\n\n### Resources\n\nAPI objects cannot be created locally. All local objects are copies of server-side data, retrieved via an API call from\na service.\n\nFor example, to create a new shipment, you must use the client's Shipment service:\n\n```csharp\nShipment myShipment = await myClient.Shipment.Create(new Dictionary\u003cstring, object\u003e\n{\n    { \"from_address\", fromAddress },\n    { \"to_address\", toAddress },\n    { \"parcel\", parcel }\n});\n```\n\nAll API-calling functions are made from the appropriate service object (rather than against the resource object), by providing the ID of the related resource. For example, to buy a shipment:\n\n```csharp\nShipment myPurchasedShipment = await myClient.Shipment.Buy(myShipment.Id, myShipment.LowestRate());\n```\n\n### Parameters\n\nMost functions in this library accept a `Dictionary\u003cstring, object\u003e` as their sole parameter, which is ultimately used as the body of the HTTP request against EasyPost's API. If you instead would like to use .NET objects to construct API call parameters, you can use the various `Parameters` classes.\n\nFor example, to create an address:\n\n```csharp\n// Use an object constructor to create the address creation parameters\nvar addressCreateParameters = new EasyPost.Parameters.Address.Create {\n    Name = \"My Name\",\n    Street1 = \"123 Main St\",\n    City = \"San Francisco\",\n    State = \"CA\",\n    Zip = \"94105\",\n    Country = \"US\",\n    Phone = \"415-123-4567\"\n};\n\n// You can add additional parameters as needed outside of the constructor\naddressCreateParameters.Company = \"My Company\";\n\n// Then convert the object to a dictionary\n// This step will validate the data and throw an exception if there are any errors (i.e. missing required parameters)\nvar addressCreateDictionary = addressCreateParameters.ToDictionary();\n\n// Pass the dictionary into the address creation method as normal\nvar address = await myClient.Address.Create(addressCreateDictionary);\n```\n\nUsing the `Parameters` classes is not required, but they can help in a number of ways:\n\n- Naturally enforces parameter types (can't assign a string to an int parameter, for example)\n- Removes the need to remember parameter names (i.e. \"name\" vs \"company\")\n- Prevents typos in parameter names\n- Removes the need to know the exact JSON schema of the HTTP request body (parameters will be serialized into the proper schema behind-the-scenes)\n- Validates parameters (i.e. ensure required parameters are present)\n- Allows for IDE auto-completion\n- Allows for IDE parameter documentation\n- Provides a more natural way to construct parameters\n- Facilitates ASP.NET Core model binding (bind an HTML form to a `Parameters` instance)\n\n### HTTP Hooks\n\nUsers can audit the HTTP requests and responses being made by the library by setting the `Hooks` property of a `ClientConfiguration` with a set of event handlers. Available handlers include:\n\n- `OnRequestExecuting` - Called before an HTTP request is made. An `OnRequestExecutingEventArgs` object is passed to the\n  handler, which contains details about the `HttpRequestMessage` that will be sent to the server.\n  - The `HttpRequestMessage` at this point is configured with all expected data (headers, body, etc.). Modifying\n    any data in the callback will NOT affect the actual request that is sent to the server.\n- `OnRequestResponseReceived` - Called after an HTTP request is made. An `RequestResponseReceivedEventArgs` object is\n  passed to the handler, which contains details about the `HttpResponseMessage` that was received from the server.\n\nUsers can interact with these details in their callbacks as they see fit (e.g. logging).\n\n```csharp\nvoid OnRequestExecutingHandler(object? sender, OnRequestExecutingEventArgs args) {\n    // Interact with details about the HttpRequestMessage here via args\n    System.Console.WriteLine($\"Making HTTP call to {args.RequestUri}\");\n}\n\nvoid OnRequestResponseReceivedHandler(object? sender, OnRequestResponseReceivedEventArgs args) {\n    // Interact with details about the HttpResponseMessage here via args\n    System.Console.WriteLine($\"Received HTTP response with status code {args.ResponseStatusCode}\");\n}\n\nClient client = new Client(new ClientConfiguration(\"EASYPOST_API_KEY\")\n{\n    Hooks = new Hooks {\n        OnRequestExecuting = OnRequestExecutingHandler,\n        OnRequestResponseReceived = OnRequestResponseReceivedHandler,\n    },\n});\n```\n\nUsers\ncan [subscribe to or unsubscribe from callbacks](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/how-to-subscribe-to-and-unsubscribe-from-events)\nat any time via the `Hooks` property of a client.\n\n```csharp\n// Add a new callback\nclient.Hooks.OnRequestExecuting += (sender, args) =\u003e { /* ... */ };\n\n// Remove a callback\nclient.Hooks.OnRequestExecuting -= OnRequestExecutingHandler;\n```\n\n### Proxies\n\nIf you need to use a proxy to make requests to the EasyPost API, you can define a custom `HttpClientHandler` on a custom `HttpClient` passed to the `ClientConfiguration` constructor.\n\n```csharp\n// Define a custom HttpClientHandler with details about the proxy\nHttpClientHandler handler = new()\n{\n    UseProxy = true,\n    Proxy = new WebProxy($\"http://localhost:8888\"),\n};\n\n// Define a custom HttpClient with the custom handler\nHttpClient httpClient = new(handler: handler);\n\n// Pass the custom HttpClient to the ClientConfiguration constructor when creating a new EasyPost Client\nClient client = new(new ClientConfiguration(FakeApikey)\n{\n    CustomHttpClient = httpClient,\n});\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-csharp\u003e or locally on\nthe [`gh-pages` branch](https://github.com/EasyPost/easypost-csharp/tree/gh-pages).\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\nIt is highly recommended to use a purpose-built IDE when working with this project such as `Visual Studio`. Most actions\nsuch as building, cleaning, and testing can be done via the GUI.\n\n```bash\n# Build project\njust build\n\n# Lint project\njust lint\njust lint-fix\n\n# Run tests (recommended to instead run via an IDE like Visual Studio)\nEASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... just test\nEASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... just coverage\n\n# Run security analysis\njust scan\n```\n\n#### NuGet Dependencies\n\nThe NuGet package dependencies for this project are listed in the `.csproj` files. This project\nuses [NuGet package locks](https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#locking-dependencies)\nto keep specific versions of dependencies. The lock files will be used during NuGet `restore`, if present.\n\nIf you need to update or alter NuGet dependencies, delete the `package.lock.json` files first. They will be regenerated\nduring the next `restore`.\n\n### Testing\n\nThe test suite in this project was specifically built to produce consistent results on every run, regardless of when\nthey run or who is running them. This project uses [EasyVCR](https://www.nuget.org/packages/EasyVCR/) to record and\nreplay HTTP requests and responses via \"cassettes\". When the suite is run, the HTTP requests and responses for each test\nfunction will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which\nsaves 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\nPII or sensitive info does not persist in version control; however, please ensure when recording or re-recording\ncassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the\ncassette.\n\n**Making Changes:** If you make an addition to this project, the request/response will get recorded automatically for\nyou if `UseVCR(\"testName\");` is included on the test function. When making changes to this project, you'll\nneed to re-record the associated cassette to force a new live API call for that test which will then record the\nrequest/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\ncompletely independent from a particular user **with the exception of the USPS carrier account ID** (\nsee [Unit Test API Keys](#unit-test-api-keys) for more information) which has a fallback value of our internal testing\nuser's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as\nreports 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\nThe following are required when you need to re-record cassettes for applicable tests (fallback values are used\notherwise):\n\n- `USPS_CARRIER_ACCOUNT_ID` (eg: one-call buying a shipment for non-EasyPost employees)\n- `REFERRAL_CUSTOMER_PROD_API_KEY` (eg: adding a credit card to a referral customer)\n\nSome tests may require a user with a particular set of enabled features such as a `Partner` user when creating\nreferrals. We have attempted to call out these functions in their respective docstrings.\n\n**NOTE** .NET Framework/.NET Standard unit tests cannot currently be run on Apple Silicon (M1, M2, etc.). Instead, run\nunit tests in one framework at a time with, e.g `just unit-test net10.0`. Valid frameworks:\n\n- `net472` (.NET Framework 4.7.2, the oldest non-EOL version of .NET Framework; will not run on Apple Silicon)\n- `net6.0` (.NET 6.0)\n- `net7.0` (.NET 7.0)\n- `net8.0` (.NET 8.0)\n- `net9.0` (.NET 9.0)\n- `net10.0` (.NET 10.0)\n\n#### Test Coverage\n\nUnit test coverage reports can be generated by running the `generate_test_reports.sh` Bash script from the root of this\nrepository.\n\nA report will be generated for each version of the library. Final reports will be stored in the `coveragereport` folder\nin the root of the repository following generation.\n\nThe script requires the following tools installed in your PATH:\n\n- `dotnet`\n- [`reportgenerator`](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage?tabs=linux#generate-reports)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasypost%2Feasypost-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasypost%2Feasypost-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasypost%2Feasypost-csharp/lists"}