{"id":28645598,"url":"https://github.com/square/square-ruby-sdk","last_synced_at":"2026-01-29T01:11:06.198Z","repository":{"id":39616211,"uuid":"193140727","full_name":"square/square-ruby-sdk","owner":"square","description":"Ruby client library for the Square API","archived":false,"fork":false,"pushed_at":"2025-12-05T15:30:41.000Z","size":9439,"stargazers_count":76,"open_issues_count":0,"forks_count":45,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-12-08T09:56:14.928Z","etag":null,"topics":["api","api-client","credit-card-payments","ecommerce","payment-processing","sdk","sdk-ruby"],"latest_commit_sha":null,"homepage":"https://developer.squareup.com/docs","language":"Ruby","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/square.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"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":"2019-06-21T18:04:27.000Z","updated_at":"2025-12-05T15:30:47.000Z","dependencies_parsed_at":"2024-02-21T23:33:46.010Z","dependency_job_id":"8476dcd9-0607-4379-86a5-fc23886d8174","html_url":"https://github.com/square/square-ruby-sdk","commit_stats":null,"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"purl":"pkg:github/square/square-ruby-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fsquare-ruby-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fsquare-ruby-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fsquare-ruby-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fsquare-ruby-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/square-ruby-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fsquare-ruby-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28670366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T19:36:09.361Z","status":"ssl_error","status_checked_at":"2026-01-22T19:36:05.567Z","response_time":144,"last_error":"SSL_read: 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":["api","api-client","credit-card-payments","ecommerce","payment-processing","sdk","sdk-ruby"],"created_at":"2025-06-13T01:39:24.445Z","updated_at":"2026-01-22T20:14:26.504Z","avatar_url":"https://github.com/square.png","language":"Ruby","readme":"# Square Ruby Library\n\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github\u0026utm_medium=github\u0026utm_campaign=readme\u0026utm_source=https%3A%2F%2Fgithub.com%2Fsquare%2Fsquare-ruby-sdk)\n[![Gem version](https://badge.fury.io/rb/square.rb.svg?new)](https://badge.fury.io/rb/square.rb)\n\nThe Square Ruby library provides convenient access to the Square API from Ruby.\n\n## Requirements\n\nUse of the Square Ruby SDK requires:\n\n* Ruby 3.2+\n\n## Installation\n\nThe Square Ruby SDK version is managed through the gem version. To use a specific version:\n\n```bash\ngem install square.rb\n```\n\nOr in your Gemfile:\n```ruby\ngem 'square.rb', '~\u003e 44.0.0'\n```\n\n## Usage\n\nFor more information, see [Using the Square Ruby SDK](https://developer.squareup.com/docs/sdks/ruby/using-ruby-sdk).\n\n```ruby\nrequire \"square\"\n\nsquare = Square::Client.new(\n  token: 'YOUR_API_KEY'\n)\n\nimage_file = Square::FileParam.from_filepath(\n  filepath: fixture_path(\"small.png\"),\n  content_type: \"image/png\"\n)\n\nresponse = square.invoices.create_invoice_attachment(\n  invoice_id: \"inv:0-ChA4-3sU9GPd-uOC3HgvFjMWEL4N\",\n  request: {\n    idempotency_key: SecureRandom.uuid,\n    description: \"A test invoice attachment\"\n  },\n  image_file: image_file\n)\n```\n\n## Legacy SDK\n\nWhile the new SDK has a lot of improvements, we at Square understand that it takes time to upgrade when there are breaking changes.\nTo make the migration easier, the new SDK also exports the legacy SDK as `square_legacy`. Here's an example of how you can use the\nlegacy SDK alongside the new SDK inside a single file:\n\n```ruby\n# Load both SDKs\nrequire 'square'\nrequire 'square_legacy'\n\n# Initialize new SDK client\nnew_client = Square::Client.new(\n  access_token: 'YOUR_SQUARE_ACCESS_TOKEN'\n)\n\n# Initialize legacy SDK client\nlegacy_client = SquareLegacy::Client.new(\n  bearer_auth_credentials: {\n    access_token: 'YOUR_SQUARE_ACCESS_TOKEN'\n  }\n)\n\n# Use new SDK for newer features\nlocations = new_client.locations.get_locations.data.locations\n\n# Use legacy SDK for specific legacy functionality\nlegacy_payment = legacy_client.payments_api.create_payment(\n  body: {\n    source_id: 'example_1234567890',\n    idempotency_key: SecureRandom.uuid,\n    amount_money: {\n      amount: 100,\n      currency: 'USD'\n    }\n  }\n)\n```\n\nWe recommend migrating to the new SDK using the following steps:\n\n1. Update your square.rb: `gem update square.rb`\n2. Search and replace all requires from `'square'` to `'square_legacy'`\n3. Update all client initializations from \n```ruby \nclient = Square::Client.new(access_token: 'token')\n```\nto \n```ruby\nclient = SquareLegacy::Client.new(\n  bearer_auth_credentials: { access_token: 'token' }\n)\n```\n4. Gradually migrate over to the new SDK by importing it from the `'square'` import.\n\n## Environments\n\nThis SDK allows you to configure different environments or custom URLs for API requests. You can either use the predefined environments or specify your own custom URL.\n\n### Environments\n```ruby\nrequire \"square\"\n\nclient = Square::Client.new(\n    base_url: Square::Environment::PRODUCTION\n)\n```\n\n### Custom URL\n```ruby\nrequire \"square\"\n\nclient = Square::Client.new(\n    base_url: \"https://custom-staging.com\"\n)\n```\n\n## Request And Response Types\n\nThe SDK exports all request and response types as Ruby classes. Simply require them with the\nfollowing namespace:\n\n```ruby\nrequire 'square'\n\n# Create a request object\nrequest = Square::CreateMobileAuthorizationCodeRequest.new(\n  location_id: 'YOUR_LOCATION_ID'\n)\n```\n\n## Errors\n\nFailed API calls will raise errors that can be rescued from granularly.\n\n```ruby\nrequire \"square\"\n\nclient = Square::Client.new(\n  base_url: Square::Environment::PRODUCTION\n)\n\nbegin\n    result = client.payments.create\nrescue Square::Errors::TimeoutError\n    puts \"API didn't respond before our timeout elapsed\"\nrescue Square::Errors::ServiceUnavailableError\n    puts \"API returned status 503, is probably overloaded, try again later\"\nrescue Square::Errors::ServerError\n    puts \"API returned some other 5xx status, this is probably a bug\"\nrescue Square::Errors::ResponseError =\u003e e\n    puts \"API returned an unexpected status other than 5xx: #{e.code} {e.message}\"\nrescue Square::Errors::ApiError =\u003e e\n    puts \"Some other error occurred when calling the API: {e.message}\"\nend\n```\n\n## Pagination\n\nList endpoints are paginated. The SDK provides methods to handle pagination:\n\n```ruby\nrequire 'square'\n\nclient = Square::Client.new(access_token: \"YOUR_TOKEN\")\n\n# Get all items using pagination\nresponse = client.bank_accounts.list\nall_bank_accounts = []\n\nwhile response.data.bank_accounts.any?\n  all_bank_accounts.concat(response.data.bank_accounts)\n  \n  # Check if there are more pages\n  if response.cursor\n    response = client.bank_accounts.list(cursor: response.cursor)\n  else\n    break\n  end\nend\n\nputs \"Total bank accounts: #{all_bank_accounts.length}\"\n```\n\n## Advanced\n\n### Additional Headers\n\nIf you would like to send additional headers as part of the request, use the `headers` request option.\n\n```ruby\nresponse = client.payments.create(..., {\n  headers: {\n    'X-Custom-Header' =\u003e 'custom value'\n  }\n})\n```\n\n### Receive Extra Properties\n\nEvery response includes any extra properties in the JSON response that were not specified in the type.\nThis can be useful for API features not present in the SDK yet.\n\nYou can receive and interact with the extra properties by accessing the raw response data:\n\n```ruby\nresponse = client.locations.create(...)\n\n# Access the raw response data\nlocation_data = response.data.to_h\n\n# Then access the extra property by its name\nundocumented_property = location_data['undocumentedProperty']\n```\n\n### Retries\n\nThe SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long\nas the request is deemed retriable and the number of retry attempts has not grown larger than the configured\nretry limit (default: 2).\n\nA request is deemed retriable when any of the following HTTP status codes is returned:\n\n- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)\n- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)\n- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)\n\nUse the `max_retries` request option to configure this behavior.\n\n```ruby\nresponse = client.payments.create(..., {\n  max_retries: 0 # override max_retries at the request level\n})\n```\n\n### Timeouts\n\nThe SDK defaults to a 60 second timeout. Use the `timeout_in_seconds` option to configure this behavior.\n\n```ruby\nresponse = client.payments.create(..., {\n  timeout_in_seconds: 30 # override timeout to 30s\n})\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n","funding_links":[],"categories":["Gems","E-Commerce \u0026 Online Paying"],"sub_categories":["SDKs and API Wrappers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fsquare-ruby-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Fsquare-ruby-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fsquare-ruby-sdk/lists"}