{"id":22089830,"url":"https://github.com/speakeasy-api/speakeasy-ruby-sdk","last_synced_at":"2025-10-11T15:16:41.597Z","repository":{"id":65615657,"uuid":"593397025","full_name":"speakeasy-api/speakeasy-ruby-sdk","owner":"speakeasy-api","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-26T14:32:38.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-16T08:57:07.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/speakeasy-api.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":"2023-01-25T22:31:31.000Z","updated_at":"2023-01-27T19:06:10.000Z","dependencies_parsed_at":"2025-08-30T10:35:35.355Z","dependency_job_id":"f6f78b7b-0bf8-4bcc-95dc-36f000ff1363","html_url":"https://github.com/speakeasy-api/speakeasy-ruby-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/speakeasy-api/speakeasy-ruby-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fspeakeasy-ruby-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fspeakeasy-ruby-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fspeakeasy-ruby-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fspeakeasy-ruby-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/speakeasy-api","download_url":"https://codeload.github.com/speakeasy-api/speakeasy-ruby-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speakeasy-api%2Fspeakeasy-ruby-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007597,"owners_count":26084333,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-01T02:14:24.702Z","updated_at":"2025-10-11T15:16:41.560Z","avatar_url":"https://github.com/speakeasy-api.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![180100416-b66263e6-1607-4465-b45d-0e298a67c397](https://user-images.githubusercontent.com/68016351/181640742-31ab234a-3b39-432e-b899-21037596b360.png)\n\nSpeakeasy is your API Platform team as a service. Use our drop in SDK to manage all your API Operations including embeds for request logs and usage dashboards, test case generation from traffic, and understanding API drift.\n\nThe Speakeasy Ruby SDK for evaluating API requests/responses. Compatible with any HTTP framework implemented on top of rack.\n\n## Supported Frameworkds\n\nTested and supported Frameworks include:\n\n* rails\n* sinatra\n\nThe Speakeasy Ruby SDK depends only upon Rack, however, so other frameworks should work.\n\n## Installation\n\nSimply install the Speakeasy Ruby SDK gem\n\n```\n  gem install speakeasy_ruby_sdk\n```\n\nor install using bundler\n\n```\n  bundle add speakeasy_ruby_sdk\n```\n\n### Minimum configuration\n\n[Sign up for free on our platform](https://www.speakeasyapi.dev/). After you've created a workspace and generated an API key enable Speakeasy in your API as follows:\n\nFor a rails project, configure Speakeasy along with your other Middlewares in your `config/application.rb` function:\n\n```ruby\n    speakeasy_config = {\n      ingestion_server_url: \"localhost:443\",\n      api_key: \"YOUR API KEY HERE\",\n      api_id: \"YOUR API ID HERE\",\n      version_id: \"YOUR API VERSION HERE\"\n    }\n\n    config.middleware.insert_before 0, SpeakeasyRubySdk::Middleware, speakeasy_config\n```\n\nBuild and deploy your app and that's it. Your API is being tracked in the Speakeasy workspace you just created\nand will be visible on the dashboard next time you log in. Visit our [docs site](https://docs.speakeasyapi.dev/) to\nlearn more.\n\n**warning** Some common middlewares, like `ActionDispatch::Cookies` remove or rewrite headers in order to provide additional functionality to your app.  In order to capture the original headers, we recommend using the `insert_before` rather than `use`ing so that it will be inserted at the front of the middleware stack.  The middleware will function at any position in the middleware stack, but may not be able to report all information to Speakeasy.\n\n### Tracking Multiple APIs configuration\n\nThe Speakeasy SDK is confirgurable using a config parameter. If you want to use the SDK to track multiple Apis or Versions from the same service you can configure individual instances of the SDK, like so:\n\n```ruby\n    speakeasy_config_1 = {\n      api_key: \"YOUR API KEY HERE\",\n      api_id: \"YOUR API ID HERE\",\n      version_id: \"YOUR API VERSION HERE\"\n    }\n    speakeasy_config_2 = {\n      api_key: \"YOUR API KEY HERE\",\n      api_id: \"YOUR API ID HERE\",\n      version_id: \"YOUR API VERSION HERE\"\n    }\n\n    config.middleware.insert_before 0, SpeakeasyRubySdk::Middleware, speakeasy_config_1\n    config.middleware.insert_before 0, SpeakeasyRubySdk::Middleware, speakeasy_config_2\n```\n\nThis allows multiple instances of the SDK to be associated with different routers or routes within your service.\n\n### Only Tracking Some Routes\n \nWe recommend using the approach native to your framework to limit the application of the Speakeasy middleware.  In Rails, that approach is [Engines](https://guides.rubyonrails.org/engines.html), in Sinatra, middleware are `use`'d by controllers, so add the directive to a Controller which is the parent of those routes you wish to track.\n\n## Request Matching\n\nThe Speakeasy SDK out of the box will do its best to match requests to your provided OpenAPI Schema. It does this by extracting the path template used by one of the supported routers or frameworks above for each request captured and attempting to match it to the paths defined in the OpenAPI Schema.  In order to enable this functionality include a `routes` directive in your speakeasy configuration - for example in Rails:\n\n```ruby\n  config = {\n    routes: Application.routes,\n    ..snip/..\n  }\n    config.middleware.use SpeakeasyRubySdk::Middleware, config\n\n```\nThis isn't always successful or even possible, meaning requests received by Speakeasy will be marked as unmatched, and potentially not associated with your Api, Version or  in the Speakeasy DashApiEndpointsboard.\n\nTo help the SDK in these situations you can provide path hints per request handler that match the paths in your OpenAPI Schema:\n\n```ruby\nclass YourController \u003c ApplicationController \n    def action\n      request.env[:path_hint] = '/api/v1/\u003cresource\u003e'\n      ..snip..\n    end\n    ..snip..\nend\n\n```\n\n## Capturing Customer IDs\n\nTo help associate requests with customers/users of your APIs you can provide a customer ID from any controller or route:\n\n```ruby\n  def index\n    request.env[:customer_id] = customer_id\n  end\n```\n\nTo easily set the `customer_id` on all requests from a Rails controller, use this standard pattern\n\n```ruby\nclass MyController \u003c ApplicationController\n    before_action set_customer_id\n\n    def index\n      ..snip..\n    end\n    \n    private\n    \n      def set_customer_id\n        req.env[:customer_id] = @session[:customer_id]\n      end\nend\n```\n\nNote: This is not required, but is highly recommended. By setting a customer ID you can easily associate requests with your customers/users in the Speakeasy Dashboard, powering filters in the Request Viewer.\n\n## Masking sensitive data\n\nSpeakeasy can mask sensitive data in the query string parameters, headers, cookies and request/response bodies captured by the SDK. This is useful for maintaining sensitive data isolation, and retaining control over the data that is captured.\n\nUsing the Only Tracking Some Routes section above you can completely ignore certain routes, causing the SDK to not selectively capture requests.\n\nBut if you would like to be more selective you can mask certain sensitive data using our middleware controller allowing you to mask fields as needed in different handlers:\n\n```ruby\n  config = {\n    ...\n    masking: [\n        SpeakeasyRubySdk::MaskConfig.new(:request_header, ['Authorization'])\n      ],\n  }\n```\nThe `masking` section of the config map takes an array of different masking options\n\n  - `SpeakeasyRubySdk::MaskConfig.new(:query_params, attributes, mask_strings)` will mask the specified query params with the optional string mask\n  - `SpeakeasyRubySdk::MaskConfig.new(:request_headers, attributes, mask_strings)` will mask the specified request_headers with the optional string mask\n  - `SpeakeasyRubySdk::MaskConfig.new(:response_headers, attributes, mask_strings)` will mask the specified response headers with the optional string mask\n  - `SpeakeasyRubySdk::MaskConfig.new(:request_cookies, attributes, mask_strings)` will mask the specified request cookies with the optional string mask\n  - `SpeakeasyRubySdk::MaskConfig.new(:response_cookies, attributes, mask_strings)` will mask the specified response cookies with the optional string mask\n  - `SpeakeasyRubySdk::MaskConfig.new(:request_body_string, attributes, mask_strings)` specified request body fields with an optional mask. Supports string fields only. Matches using regex.\n  - `SpeakeasyRubySdk::MaskConfig.new(:request_body_number, attributes, mask_strings)` specified request body fields with an optional mask. Supports numeric fields only. Matches using regex.\n  - `SpeakeasyRubySdk::MaskConfig.new(:response_body_string, attributes, mask_strings)` specified response body fields with an optional mask. Supports string fields only. Matches using regex.\n  - `SpeakeasyRubySdk::MaskConfig.new(:response_body_number, attributes, mask_strings)` specified response body fields with an optional mask. Supports numeric fields only. Matches using regex.\n\nIn all of the above instances, you may optionally provide an array of mask strings.  If you leave this field out, or pass an empty array, the system will mask with our default mask value \"__masked__\" (-12321 for numbers).  If you provide an array with a single value, then the system will mask all matches with that value.  If you provide more than one value, then each match will be replaced by the corresponding mask values (if there are too few, then the remaining matches will receive our default mask value).\n\nYou may provide as many MaskConfig objects as you desire.\n\n## Embedded Request Viewer Access Tokens\n\nThe Speakeasy SDK can generate access tokens for the [https://docs.speakeasyapi.dev/speakeasy-user-guide/request-viewer/embedded-request-viewer](Embedded Request Viewer) that can be used to view requests captured by the SDK.\n\nFor documentation on how to configure filters, find that [https://docs.speakeasyapi.dev/speakeasy-user-guide/request-viewer/embedded-request-viewer](HERE).\n\nYou are able to request an `EmbeddedAccessToken` from any location in your application, but most likely you will make such a request inside of a `Controller` method.\n\n```rb\nclass MyController \u003c ApplicationController\n\n  def action\n    access_token = SpeakeasyRubySdk::get_embedded_access_token 'customer_id', '=', \u003csome_customer_id\u003e, {api_key: '..snip..'}\n  end\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeakeasy-api%2Fspeakeasy-ruby-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspeakeasy-api%2Fspeakeasy-ruby-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeakeasy-api%2Fspeakeasy-ruby-sdk/lists"}