bitmicrosys/sharpsports-php
Composer 安装命令:
composer require bitmicrosys/sharpsports-php
包简介
PHP Laravel SDK for SharpSports API
README 文档
README
Hey there! 👋 This is an unofficial PHP/Laravel SDK for the SharpSports API. Threw this together in a few hours because I needed it for a project. It works pretty well, but you know... it's not perfect.
⚠️ Disclaimer
This is NOT an official SharpSports product. I'm just some dev who needed to integrate their API. Use at your own risk! If something breaks, don't blame me (or SharpSports). If you find bugs, just open an issue or better yet, submit a PR!
Features
- ✅ Covers most (all?) SharpSports API endpoints
- ✅ Laravel service provider and facade (fancy!)
- ✅ Model classes that make sense
- ✅ Handles those weird API responses pretty well
- ✅ Error handling that actually works
- ✅ Probably won't break your app (no promises though)
Installation
Install the package via Composer:
composer require bitmicrosys/sharpsports-php
Laravel Auto-Discovery
The package supports Laravel's auto-discovery feature. If you're using Laravel 5.5+, the service provider and facade will be automatically registered.
Manual Registration (Laravel < 5.5)
Add the service provider to your config/app.php:
'providers' => [ // ... Bitmicrosys\SharpsportsPhp\SharpsportsServiceProvider::class, ],
Add the facade to your config/app.php:
'aliases' => [ // ... 'SharpSports' => Bitmicrosys\SharpsportsPhp\Facades\SharpSports::class, ],
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=sharpsports-config
Add your SharpSports API key to your .env file:
SHARPSPORTS_API_KEY=your_api_key_here
Usage
Basic Usage
use Bitmicrosys\SharpsportsPhp\SharpSports; // Initialize the client $sharpSports = new SharpSports('your_api_key'); // Get all books $books = $sharpSports->books()->list(); // Get active books only $activeBooks = $sharpSports->books()->getActive();
Using Laravel Facade
use SharpSports; // Get all books $books = SharpSports::books()->list(); // Get a specific book $book = SharpSports::books()->find('BOOK_pPg9ABaPSj2mL6qoMTKR1A'); // Get bettors $bettors = SharpSports::bettors()->list(); // Get bet slips for a bettor $betSlips = SharpSports::betSlips()->getByBettor('bettor_id');
Using Dependency Injection
use Bitmicrosys\SharpsportsPhp\SharpSports; class BettingController extends Controller { public function __construct(private SharpSports $sharpSports) { // } public function getBooks() { return $this->sharpSports->books()->getActive(); } }
Complete API Coverage
The SharpSports PHP SDK provides comprehensive coverage of all SharpSports API endpoints:
Books
// Get all books $books = $sharpSports->books()->list(); // Get active books $activeBooks = $sharpSports->books()->getActive(); // Get books that require SDK $sdkBooks = $sharpSports->books()->getSdkRequired(); // Find a specific book $book = $sharpSports->books()->find('BOOK_ID');
Bettors
// Get all bettors $bettors = $sharpSports->bettors()->list(); // Get bettor details $bettor = $sharpSports->bettors()->get('bettor_id'); // Get bettor metadata $metadata = $sharpSports->bettors()->getMetadata('bettor_id'); // Refresh bettor data $response = $sharpSports->bettors()->refresh('bettor_id');
Bettor Accounts
// Get all bettor accounts $accounts = $sharpSports->bettorAccounts()->list(); // Get accounts for a specific bettor $accounts = $sharpSports->bettorAccounts()->getByBettor('bettor_id'); // Refresh an account $response = $sharpSports->bettorAccounts()->refresh('account_id'); // Pause an account $response = $sharpSports->bettorAccounts()->pause('account_id');
Bet Slips
// Get all bet slips $betSlips = $sharpSports->betSlips()->list(); // Get bet slips for a bettor $betSlips = $sharpSports->betSlips()->getByBettor('bettor_id'); // Get bet slips for an account $betSlips = $sharpSports->betSlips()->getByBettorAccount('account_id'); // Check bet slip availability $availability = $sharpSports->betSlips()->checkAvailability($data);
Context Operations
// Sync bets $response = $sharpSports->context()->betSync($data); // Place bets $response = $sharpSports->context()->betPlace($data); // Get best price $response = $sharpSports->context()->bestPrice($data);
Events, Markets, Sports, etc.
// Events $events = $sharpSports->events()->list(); $event = $sharpSports->events()->get('event_id'); // Markets $markets = $sharpSports->markets()->list(); $market = $sharpSports->markets()->get('market_id'); // Sports $sports = $sharpSports->sports()->list(); $sport = $sharpSports->sports()->get('sport_id'); // Leagues $leagues = $sharpSports->leagues()->list(); // Teams $teams = $sharpSports->teams()->list(); // Players $players = $sharpSports->players()->list();
Webhooks
// Subscribe to webhooks $response = $sharpSports->webhooks()->subscribe($data); // Get webhook logs $logs = $sharpSports->webhooks()->getLogs();
Model Classes
The SDK includes model classes for type-safe responses:
use Bitmicrosys\SharpsportsPhp\Models\Book; $books = $sharpSports->books()->list(); foreach ($books as $book) { echo $book->name; // BetMGM echo $book->abbr; // mg echo $book->isActive(); // true/false echo $book->requiresSdk(); // true/false }
Available models:
BookBettorBettorAccountBetSlip
Error Handling
The SDK throws SharpsportsException for API errors:
use Bitmicrosys\SharpsportsPhp\SharpsportsException; try { $books = $sharpSports->books()->list(); } catch (SharpsportsException $e) { echo "API Error: " . $e->getMessage(); echo "Status Code: " . $e->getCode(); }
Configuration Options
You can customize the HTTP client by passing options to the constructor:
$sharpSports = new SharpSports('your_api_key', [ 'timeout' => 60, 'connect_timeout' => 10, 'headers' => [ 'User-Agent' => 'MyApp/1.0', ], ]);
All Available Methods
Complete API Coverage
The SDK provides complete coverage of all SharpSports API objects:
- 📖 Books - Sportsbook information and status
- 📝 Articles - AI-generated SEO articles
- 🌎 BookRegions - Regional sportsbook availability
- 👤 Bettors - User accounts and profiles
- 📱 BettorAccounts - Connected sportsbook accounts
- 💰 BetSlips - Betting history and slips
- 🔄 RefreshResponses - Account refresh status
- 🎟️ Events - Sports events and games
- 📋 Markets - Betting markets
- 🏷️ MarketSelections - Market options
- 🛒 MarketOffers - Available offers
- 🏛️ Prices - Odds and pricing
- 🏈 Sports - Available sports
- 🏟️ Leagues - Sports leagues
- 🎽 Teams - Sports teams
- ⛹️♂️ Players - Player information
- 🕞 Segments - Market segments
- 🧮 Metrics - Performance metrics
- 🔗 Context - Bet placement context
- 🪝 Webhooks - Event subscriptions
Each service provides standard methods like list(), get(), and specialized methods for specific functionality.
Error Handling
use Bitmicrosys\SharpsportsPhp\SharpsportsException; try { $books = $sharpSports->books()->list(); } catch (SharpsportsException $e) { echo "API Error: " . $e->getMessage(); echo "Status Code: " . $e->getCode(); }
Contributing
Found a bug? Cool, fix it and send a PR. Want to add something? Go for it! This is open source, baby! 🚀
Known Issues
- Price API returns different response structures depending on parameters (single object vs array). Yeah, it's weird, but we handle it.
- Some endpoints need specific parameters or they'll yell at you
- Haven't tested everything extensively (who has time for that?)
- Probably other stuff I haven't found yet
License
This package is open-sourced software licensed under the MIT license. See the license file for the full "I'm not responsible for anything" legal text.
Support
Having issues? Open a GitHub issue. Want to chat? Sorry, I'm probably coding. But seriously, just open an issue and I'll try to help when I can.
Credits
- SharpSports for having an API (even though their docs could be better 😅)
- Coffee for keeping me awake while coding this
- Stack Overflow for... you know why
API Documentation
For the official API docs (good luck understanding them sometimes), visit SharpSports API Reference.
Remember: This is unofficial. If SharpSports changes their API and this breaks, well... ¯_(ツ)_/¯
bitmicrosys/sharpsports-php 适用场景与选型建议
bitmicrosys/sharpsports-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sdk」 「laravel」 「sharpsports」 「sports betting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bitmicrosys/sharpsports-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bitmicrosys/sharpsports-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bitmicrosys/sharpsports-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-11