{"id":16747825,"url":"https://github.com/janko/flickr-objects","last_synced_at":"2025-03-21T22:31:47.275Z","repository":{"id":4525478,"uuid":"5665551","full_name":"janko/flickr-objects","owner":"janko","description":"An object-oriented wrapper for the Flickr API.","archived":false,"fork":false,"pushed_at":"2019-09-17T17:19:07.000Z","size":1489,"stargazers_count":28,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:43:57.760Z","etag":null,"topics":["api-wrapper","flickr-api","ruby"],"latest_commit_sha":null,"homepage":"http://janko-m.github.com/flickr-objects/","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/janko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-04T00:29:44.000Z","updated_at":"2023-01-14T13:42:04.000Z","dependencies_parsed_at":"2022-09-06T05:01:39.771Z","dependency_job_id":null,"html_url":"https://github.com/janko/flickr-objects","commit_stats":null,"previous_names":["janko-m/flickr-objects"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janko%2Fflickr-objects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janko%2Fflickr-objects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janko%2Fflickr-objects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janko%2Fflickr-objects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janko","download_url":"https://codeload.github.com/janko/flickr-objects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880293,"owners_count":20525506,"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":["api-wrapper","flickr-api","ruby"],"created_at":"2024-10-13T02:11:00.567Z","updated_at":"2025-03-21T22:31:46.876Z","avatar_url":"https://github.com/janko.png","language":"Ruby","readme":"# Flickr Objects\n\nThis gem is an object-oriented wrapper for the [Flickr API](http://flickr.com/api).\n\n- Web page: [http://janko.github.com/flickr-objects](http://janko.github.com/flickr-objects)\n- Source code: [https://github.com/janko/flickr-objects](https://github.com/janko/flickr-objects)\n- API Documentation: [http://rubydoc.info/github/janko/flickr-objects/master/frames](http://rubydoc.info/github/janko/flickr-objects/master/frames)\n\nThe gem has been tested on the following Ruby versions:\n\n- MRI 1.9.3\n- MRI 2.0\n- MRI 2.1\n\n## Installation and setup\n\nAdd it to your `Gemfile`, and run `bundle install`.\n\n```ruby\ngem \"flickr-objects\"\n```\n\nNow create an initializer where you set your Flickr credentials.\n\n```ruby\nFlickr.configure do |config|\n  config.api_key       = \"API_KEY\"\n  config.shared_secret = \"SHARED_SECRET\"\nend\n```\n\nIf you don't have them yet, you can apply for them\n[here](http://www.flickr.com/services/apps/create/apply).\n\nFor list of possible configuration options, see\n[`Flickr::Configuration`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/Configuration).\n\n## Usage\n\nThis gem maps [Flickr's API methods](http://flickr.com/api) to Ruby methods.\n\n```ruby\nFlickr.photos.search(...)   # flickr.photos.search\nFlickr.person.get_sets(...) # flickr.photosets.getList\n```\n\nFor the list of all API methods (and their related Flickr's methods), see\n[`Flickr::Api`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/Api).\nThese methods are included to the `Flickr` module.\n\nExample:\n\n```ruby\nphotos = Flickr.photos.search(user_id: \"78733179@N04\") #=\u003e [#\u003cFlickr::Object::Photo: ...\u003e, #\u003cFlickr::Object::Photo: ...\u003e, ...]\n\nphoto = photos.first\nphoto.id                 #=\u003e \"231233252\"\nphoto.title              #=\u003e \"My cat\"\nphoto.visibility.public? #=\u003e true\n\nperson = Flickr.people.find(\"78733179@N04\")\nset = person.sets.first\nset.id           #=\u003e \"11243423\"\nset.photos_count #=\u003e 40\n```\n\nFew notes here:\n\n- flickr-objects distinguishes **instance** from **class** API methods. So,\n  `Flickr.photos.search` is a **class** API method. And `Flickr.people.get_sets`\n  is by its nature an **instance** API method, because we're finding sets\n  *from a person*; in that case it's nicer to call `#get_sets` on an instance of\n  person.\n- Flickr objects can always be instantiated with `Flickr.\u003cobjects\u003e.find(id)`\n  (in the above example we did `Flickr.people.find(id)`).\n\n## Arguments to API methods\n\nBy its nature, API methods always accept a hash of parameters. Using that approach,\nthis would be the call for \"flickr.people.findByEmail\":\n\n```ruby\nFlickr.people.find_by_email(find_email: \"janko.marohnic@gmail.com\")\n```\n\nBut that looks lame. Luckily, in these kind of methods flickr-objects improves\nthe argument list:\n\n```ruby\nFlickr.people.find_by_email(\"janko.marohnic@gmail.com\")\n```\n\nThese arguments are documented:\n[`Flickr::Api::Person#find_by_email`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/Api/Person#find_by_email-instance_method).\n\n## Sizes\n\n```ruby\nperson = Flickr.person.find(\"78733179@N04\")\nphoto = person.public_photos(sizes: true).first\n\nphoto.small!(320)\nphoto.source_url #=\u003e \"http://farm9.staticflickr.com/8191/8130464513_780e01decd_n.jpg\"\nphoto.width      #=\u003e 320\nphoto.height     #=\u003e 280\n\nphoto.medium!(500)\nphoto.width      #=\u003e 500\n```\n\nIt is important here that you pass `sizes: true` to `Flickr::Person#public_photos`.\nSo, in your (Rails) application, you could use it like this:\n\n```ruby\nclass PhotosController \u003c ApplicationController\n  def index\n    person = Flickr.people.find(\"78733179@N04\")\n    @photos = person.public_photos(sizes: true).map(\u0026:medium500!)\n  end\nend\n```\n```erb\n\u003c% @photos.each do |photo| %\u003e\n  \u003c%= image_tag photo.source_url, size: \"#{photo.width}x#{photo.height}\" %\u003e\n\u003c% end %\u003e\n```\n\nTo find out more, see [`Flickr::Object::Photo`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/Object/Photo).\n\n## Authentication\n\nYou may need to make authenticated API requests, using an access token.\n\n```ruby\nflickr = Flickr.new(\"ACCESS_TOKEN_KEY\", \"ACCESS_TOKEN_SECRET\")\n\n# It has the same interface as `Flickr`\nflickr.test_login #=\u003e {\"id\" =\u003e \"78733179@N04\", \"username\" =\u003e ...}\nflickr.people.find(\"78733179@N04\").get_photos #=\u003e [#\u003cFlickr::Photo ...\u003e, #\u003cFlickr::Photo, ...\u003e, ...]\n```\n\nFor details on how to authenticate the user, that is, obtain his access token, see\n[`Flickr::OAuth`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/OAuth).\n\nIf you want, you can also assign the access token globally in your configuration.\n\n```ruby\nFlickr.configure do |config|\n  config.access_token_key = \"ACCESS_TOKEN_KEY\"\n  config.access_token_secret = \"ACCESS_TOKEN_SECRET\"\nend\n```\n\nNaturally, this way you don't need to create an instance like above.\n\n## Upload\n\n```ruby\nphoto_id = Flickr.upload(\"/path/to/photo.jpg\", title: \"Dandelions\")\nphoto = Flickr.photos.find(photo_id).get_info!\nphoto.title #=\u003e \"Dandelions\"\n```\n\nSee [`Flickr.upload`](http://rubydoc.info/github/janko/flickr-objects/master/Flickr/Api/General#upload-instance_method).\n\n## Pagination\n\n```ruby\nFlickr.configure do |config|\n  config.pagination = :will_paginate\nend\n```\n```ruby\n@photos = Flickr.photos.search(user_id: \"78733179@N04\", page: params[:page], per_page: 10)\n```\n```erb\n\u003c%= will_paginate @photos %\u003e\n```\n\nFlickr gives you pagination on almost every request that returns a collection of objects.\nThis gem supports both [WillPaginate](https://github.com/mislav/will_paginate) (`:will_paginate`)\nand [Kaminari](https://github.com/amatsuda/kaminari) (`:kaminari`).\n\n## Caching\n\nTo enable caching responses, just pass in a cache object (an object that responds\nto `#read`, `#write` and `#fetch`) in the configuration.\n\n```ruby\nrequire \"active_support/cache\"\nrequire \"active_support/core_ext/numeric/time\"\n\nFlickr.configure do |config|\n  config.cache = ActiveSupport::Cache::MemoryStore(expires_in: 1.week)\nend\n```\n\n```ruby\nFlickr.photos.recent # Makes an API call\nFlickr.photos.recent # Uses the cache\n```\n\n## Few words\n\nMany of the API methods are not covered yet (because they are so many).\nI believe I covered all the important ones, but if you wish for me to\ncover certain new ones, feel free to contact me via [Twitter](https://twitter.com/jankomarohnic).\nI also wouldn't mind getting a pull request ;)\n\n## Social\n\nYou can follow me on Twitter, I'm [@jankomarohnic](https://twitter.com/jankomarohnic).\n\n## License\n\nThis project is released under the [MIT license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanko%2Fflickr-objects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanko%2Fflickr-objects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanko%2Fflickr-objects/lists"}