Download the PHP package asteriskpound/usps-php-api without Composer
On this page you can find all versions of the php package asteriskpound/usps-php-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package usps-php-api
USPS PHP API
A comprehensive PHP library for integrating with the USPS Web APIs, providing easy access to shipping rates, address validation, location services, and more.
Features
- ✅ Address Validation - Validate and standardize US addresses
- ✅ Domestic Pricing - Get shipping rates for domestic packages
- ✅ International Pricing - Calculate international shipping costs
- ✅ Location Services - Find USPS facilities and drop-off locations
Requirements
- PHP 8.1 or higher
- USPS API credentials (Consumer Key and Consumer Secret)
Installation
Install via Composer:
Getting Started
1. Obtain USPS API Credentials
- Visit the USPS Developer Portal
- Register for an account
- Create a new application to get your Consumer Key and Consumer Secret
- Note: Some APIs require additional business account setup
2. Basic Setup
3. Configuration Options
Usage Examples
Address Validation
Domestic Pricing
International Pricing
Location Services
Available Enums
The library provides comprehensive enums for type safety:
MailClass- Available mail classes (Priority Mail, Ground Advantage, etc.)ProcessingCategory- Package processing categories (Machinable, Letters, etc.)RateIndicator- Rate indicators (Single Piece, Bulk, etc.)PriceType- Pricing types (Retail, Commercial, etc.)ExtraService- Additional services (Tracking, Insurance, Signature, etc.)UnitOfMeasurement- Weight and dimension unitsFacilityType- USPS facility typesAddressType- Address classification types
Testing
The library includes comprehensive tests. To run them:
1. Set Up Test Environment
Create a .env file in the project root:
2. Run Tests
3. Test Configuration
The test suite includes:
- Unit tests for all services
- Integration tests with USPS APIs
- Validation tests for request/response schemas
- Error handling tests
Error Handling
The library provides specific exception types:
Advanced Configuration
Custom Cache Implementation
Implement PSR-6 caching for improved performance:
Request Validation
Control request validation behavior:
Custom Timeout
Adjust request timeouts:
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
./vendor/bin/phpunit) - Commit your changes (
git commit -m 'Add feature') - Push to the branch (
git push origin feature/feature) - Open a Pull Request
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: API Documentation
Changelog
v0.1.0 (Current)
- Initial release
- Address validation support
- Domestic and international pricing
- Location services
- Comprehensive test suite
- Full enum support for type safety
Note: This library is not officially affiliated with the United States Postal Service. USPS is a trademark of the United States Postal Service.
All versions of usps-php-api with dependencies
guzzlehttp/guzzle Version ^7.0
league/openapi-psr7-validator Version ^0.22
marc-mabe/php-enum Version ^4.6