{"id":15145756,"url":"https://github.com/soundcloud/soundcloud-ruby","last_synced_at":"2025-10-19T16:32:11.201Z","repository":{"id":23530033,"uuid":"263658726","full_name":"soundcloud/soundcloud-ruby","owner":"soundcloud","description":"Official SoundCloud API Wrapper for Ruby.","archived":false,"fork":false,"pushed_at":"2023-04-09T21:04:46.000Z","size":105,"stargazers_count":7,"open_issues_count":0,"forks_count":13,"subscribers_count":72,"default_branch":"master","last_synced_at":"2025-01-29T21:23:47.149Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developers.soundcloud.com","language":"Ruby","has_issues":false,"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/soundcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-13T14:47:26.000Z","updated_at":"2024-10-10T11:41:29.000Z","dependencies_parsed_at":"2024-01-08T18:03:34.268Z","dependency_job_id":"79a679c9-c815-4942-bdc9-76a52fa474cd","html_url":"https://github.com/soundcloud/soundcloud-ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsoundcloud-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsoundcloud-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsoundcloud-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsoundcloud-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soundcloud","download_url":"https://codeload.github.com/soundcloud/soundcloud-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237172113,"owners_count":19266614,"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","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-09-26T11:42:32.788Z","updated_at":"2025-10-19T16:32:10.851Z","avatar_url":"https://github.com/soundcloud.png","language":"Ruby","readme":"# ⚠️⚠️DEPRECATED - NO LONGER MAINTAINED⚠️⚠️\nThis repository is no longer maintained by the SoundCloud team due to capacity constraints. We're instead focusing our efforts on improving the API \u0026 the developer platform. Please note the repo might be not in sync with the latest API changes. \n\nWe recommend the community to fork this repo in order to maintain the SDK. We'd be more than happy to make a reference on our developer portal that the developers can use different SDKs build by the community. In case you need to reach out to us, please head over to https://github.com/soundcloud/api/issues  \n\n---\n\n# SoundCloud API Wrapper\n\n[![Build Status](https://travis-ci.org/soundcloud/soundcloud-ruby.png?branch=master)](https://travis-ci.org/soundcloud/soundcloud-ruby)\n\n## Description\nThe official SoundCloud API wrapper. It provides simple methods to handle\nauthorization and to execute HTTP calls.\n\n## Installation\n```sh\ngem install soundcloud\n```\n\n## Examples\n\nThe following examples are for the [latest gem version](https://rubygems.org/gems/soundcloud).\n\n```ruby\nSoundCloud::VERSION\n# =\u003e \"0.3.7\"\n```\n\n#### OAuth2 client credentials flow\n```ruby\n# register a new client, which will exchange the client_id, client_secret for an access_token\nclient = SoundCloud.new({\n  :client_id     =\u003e YOUR_CLIENT_ID,\n  :client_secret =\u003e YOUR_CLIENT_SECRET,\n})\n```\n\n#### OAuth2 authorization code flow\n```ruby\n# register a new client, providing the client_id, client_secret and redirect_uri\nclient = SoundCloud.new({\n  :client_id     =\u003e YOUR_CLIENT_ID,\n  :client_secret =\u003e YOUR_CLIENT_SECRET,\n  :redirect_uri  =\u003e YOUR_REDIRECT_URI,\n})\n\nredirect client.authorize_url()\n# the user should be redirected to \"https://soundcloud.com/connect?client_id=YOUR_CLIENT_ID\u0026response_type=code\u0026redirect_uri=YOUR_REDIRECT_URI\"\n# after granting access they will be redirected back to YOUR_REDIRECT_URI with an authorization code present\n# ex: \u003cYOUR_REDIRECT_URI\u003e?code=XXX\n# in your respective handler you can build an exchange token from the transmitted code\nclient.exchange_token(:code =\u003e params[:code])\n```\n\n#### OAuth2 refresh token flow, upload a track and print its link\n```ruby\n# register a new client and exchange an existing refresh_token for an access_token\n# note: refresh_token can also be acquired from authorization code/client_credentials flows.\n# use this flow to automatically update the token when it expires.\nclient = SoundCloud.new({\n  :client_id     =\u003e YOUR_CLIENT_ID,\n  :client_secret =\u003e YOUR_CLIENT_SECRET,\n  :refresh_token =\u003e SOME_REFRESH_TOKEN\n})\n\n# upload a new track with audio.mp3 as audio and image.jpg as artwork\ntrack = client.post('/tracks', :track =\u003e {\n  :title      =\u003e 'a new track',\n  :asset_data =\u003e File.new('audio.mp3')\n})\n\n# print new tracks link\nputs track.permalink_url\n```\n\n\n#### Print links of the 10 most recent tracks\n```ruby\n# get newest tracks\ntracks = client.get('/tracks', :limit =\u003e 10)\n# print each link\ntracks.each do |track|\n  puts track.permalink_url\nend\n```\n\n#### Resolve a track url and print its id\n```ruby\n# call the resolve endpoint with a track url\ntrack = client.get('/resolve', :url =\u003e \"http://soundcloud.com/forss/flickermood\")\n\n# print the track id\nputs track.id\n```\n\n### Initializing a client with an access token and updating the users profile description\n```ruby\n# initializing a client with an access token\nclient = SoundCloud.new(:access_token =\u003e A_VALID_TOKEN)\n\n# updating the users profile description\nclient.put(\"/me\", :user =\u003e {:description =\u003e \"a new description\"})\n```\n\n### Add a track to a playlist / set\n```ruby\n# get my last playlist\nplaylist = client.get(\"/me/playlists\").first\n\n# get ids of contained tracks\ntrack_ids = playlist.tracks.map(\u0026:id) # =\u003e [22448500, 21928809]\n\n# adding a new track 21778201\ntrack_ids \u003c\u003c 21778201 # =\u003e [22448500, 21928809, 21778201]\n\n# map array of ids to array of track objects:\ntracks = track_ids.map{|id| {:id =\u003e id}} # =\u003e [{:id=\u003e22448500}, {:id=\u003e21928809}, {:id=\u003e21778201}]\n\n# send update/put request to playlist\nplaylist = client.put(playlist.uri, :playlist =\u003e {\n  :tracks =\u003e tracks\n})\n\n# print the list of track ids of the updated playlist:\np playlist.tracks.map(\u0026:id)\n```\n\n## Interface\n#### SoundCloud.new(options={})\nStores the passed options and calls exchange_token in case all options are passed\nthat allow an exchange of tokens.\n\n#### SoundCloud#exchange_token(options={})\nStores the passed options and tries to exchange tokens if no access_token is\npresent and:\n\n* `client_id`, `client_secret` is present (client credentials flow).\n* `refresh_token`, `client_id` and `client_secret` is present (refresh token flow).\n* `client_id`, `client_secret`, `redirect_uri`, and `code` is present (authorization code flow).\n\n#### SoundCloud#authorize_url(options={})\nStores the passed options except for `state` and `display` and returns an\nauthorize url (a part of authorization code flow).\nThe `client_id` and `redirect_uri` options has to be present to\ngenerate the authorize url. The `state` and `display` options can be used to\nset the parameters accordingly in the authorize url.\n\n#### SoundCloud#get, SoundCloud#post, SoundCloud#put, SoundCloud#delete, SoundCloud#head\nThese methods expose all available HTTP methods. They all share the signature\n`(path_or_uri, query={}, options={})`. The query hash will be merged with the\noptions hash and passed to httparty. Depending on if the client is authorized\nit will either add the client_id or the access_token as a query parameter. In\ncase an access_token is expired and a `refresh_token`, `client_id` and\n`client_secret` is present it will try to refresh the `access_token` and retry\nthe call. The response is either a Hashie::Mash or an array of Hashie::Mashes.\nThe mashes expose all resource attributes as methods and the original response\nthrough `HashResponseWrapper#response`.\n\n#### SoundCloud#client_id, client_secret, access_token, refresh_token, use_ssl?\nThese methods are accessors for the stored options.\n\n#### SoundCloud#on_exchange_token\nA Proc passed to on_exchange_token will be called each time a token was\nsuccessfully exchanged or refreshed\n\n#### SoundCloud#expires_at\nReturns a date based on the `expires_in` attribute returned from a token\nexchange.\n\n#### SoundCloud#expired?\nWill return true or false depending on if `expires_at` is in the past.\n\n#### Error Handling\nIn case a request was not successful a SoundCloud::ResponseError will be\nraised. The original HTTParty response is available through\n`SoundCloud::ResponseError#response`.\n\n## Documentation\n\nFor more code examples, please visit the [SoundCloud API Documentation](http://developers.soundcloud.com/docs).\n","funding_links":[],"categories":["Third-party APIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fsoundcloud-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoundcloud%2Fsoundcloud-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fsoundcloud-ruby/lists"}