pixabay-api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +109 -34
- data/Rakefile +1 -1
- data/lib/pixabay.rb +24 -18
- data/lib/pixabay/config.rb +1 -1
- data/lib/pixabay/version.rb +1 -1
- data/pixabay.gemspec +4 -4
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbeddc67dbd49cd5ba5cf6ad6f588ef7a6142b87
|
4
|
+
data.tar.gz: 1efd514807ce1edd9f3a8a83d2a57e824625542d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49c4f40411da4dd62529e44e6bc2e8cd2c4bfce936f1342b9d5223acf42e6c2b39d75a2c3f9a7e78aa7ae96038f6c35a91838433f7fa15ce9d1f8b1dbcfeaf8a
|
7
|
+
data.tar.gz: d708d3d87cb85d24f8699ae348fb742e29d5ba457eaa8770bee21f8a427733db9a4d66b0e37c5146fced2bb7acb8834067fd36bb3924c1b79f5cb02d6c8fde8d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Pixabay
|
2
|
+
[![Build Status](https://travis-ci.org/kimsuelim/pixabay.svg?branch=master)](https://travis-ci.org/kimsuelim/pixabay)
|
2
3
|
|
3
4
|
## DESCRIPTION:
|
4
5
|
|
@@ -28,60 +29,134 @@ If you want to configure pixabay through an initializer (e.g. `config/initialize
|
|
28
29
|
|
29
30
|
```ruby
|
30
31
|
Pixabay.configure do |config|
|
31
|
-
config.
|
32
|
+
config.key = "Your API key"
|
32
33
|
config.timeout = 10
|
33
34
|
end
|
34
35
|
```
|
35
36
|
|
36
|
-
|
37
|
+
### Search Images
|
37
38
|
|
38
39
|
```ruby
|
40
|
+
require 'pixabay'
|
39
41
|
client = Pixabay.new
|
40
|
-
client.photos(
|
42
|
+
res = client.photos(q: "yellow flower", safesearch: true, page: 1, per_page: 30)
|
43
|
+
res["total"] # 15526
|
44
|
+
res["totalHits"] # 500
|
45
|
+
res["hits"] # pictures
|
41
46
|
```
|
42
47
|
|
43
|
-
|
48
|
+
This will find 30 yellow flower pictures.
|
49
|
+
If you want high resolution pictures, see (https://pixabay.com/api/docs/?request_full_access)
|
50
|
+
|
51
|
+
Avalable Request parameters see [https://pixabay.com/api/docs/](https://pixabay.com/api/docs/)
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# Default Request parameters
|
55
|
+
{
|
56
|
+
q: nil, lang: "en", id: nil,
|
57
|
+
response_group: "image_details", image_type: "all", orientation: "all", category: nil,
|
58
|
+
min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
|
59
|
+
order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
Example responses
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
{
|
67
|
+
"totalHits"=>500,
|
68
|
+
"hits"=>[
|
69
|
+
{
|
70
|
+
"previewHeight"=>93,
|
71
|
+
"likes"=>87,
|
72
|
+
"favorites"=>61,
|
73
|
+
"tags"=>"blossom, bloom, flower",
|
74
|
+
"webformatHeight"=>400,
|
75
|
+
"views"=>28270,
|
76
|
+
"webformatWidth"=>640,
|
77
|
+
"previewWidth"=>150,
|
78
|
+
"comments"=>3,
|
79
|
+
"downloads"=>10382,
|
80
|
+
"pageURL"=>"https://pixabay.com/en/blossom-bloom-flower-yellow-close-195897/",
|
81
|
+
"previewURL"=>"https://cdn.pixabay.com/photo/2013/10/15/09/20/flower-195897_150.jpg",
|
82
|
+
"webformatURL"=>"https://pixabay.com/get/e83cb40721f31c2ad65a5854e74b4f94e471e6c818b5184690f0c97faeea_640.jpg",
|
83
|
+
"imageWidth"=>4000,
|
84
|
+
"user_id"=>48777,
|
85
|
+
"user"=>"Josch13", "type"=>"photo",
|
86
|
+
"id"=>195897,
|
87
|
+
"userImageURL"=>"https://cdn.pixabay.com/user/2013/11/05/02-10-23-764_250x250.jpg",
|
88
|
+
"imageHeight"=>2501
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"previewHeight"=>99,
|
92
|
+
...
|
93
|
+
},
|
94
|
+
...
|
95
|
+
],
|
96
|
+
"total"=>15526
|
97
|
+
}
|
98
|
+
```
|
99
|
+
|
100
|
+
### Search Videos
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require 'pixabay'
|
104
|
+
client = Pixabay.new
|
105
|
+
res = client.videos(q: "yellow flower", safesearch: true, page: 1, per_page: 30)
|
106
|
+
res["total"] # 5593
|
107
|
+
res["totalHits"] # 500
|
108
|
+
res["hits"] # videos
|
109
|
+
```
|
110
|
+
|
111
|
+
This will find 30 yellow flower videos.
|
112
|
+
|
113
|
+
Avalable Request parameters see [https://pixabay.com/api/docs/](https://pixabay.com/api/docs/)
|
44
114
|
|
45
115
|
```ruby
|
46
116
|
# Default Request parameters
|
47
117
|
{
|
48
|
-
|
49
|
-
|
50
|
-
min_height: 0, editors_choice: false, safesearch: false,
|
51
|
-
order:
|
118
|
+
q: nil, lang: "en", id: nil,
|
119
|
+
video_type: "all", category: nil,
|
120
|
+
min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
|
121
|
+
order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
|
52
122
|
}
|
53
123
|
```
|
54
124
|
|
55
125
|
Example responses
|
56
126
|
|
57
127
|
```ruby
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
128
|
+
{
|
129
|
+
"totalHits"=>500,
|
130
|
+
"hits"=>[
|
131
|
+
{
|
132
|
+
"picture_id"=>"583475757",
|
133
|
+
"videos"=>{
|
134
|
+
"large"=>{"url"=>"", "width"=>0, "size"=>0, "height"=>0},
|
135
|
+
"small"=>{"url"=>"https://player.vimeo.com/external/176277723.sd.mp4?s=a9a3531634d2c42b6e62d10bea241133267589aa&profile_id=165", "width"=>960, "size"=>17298015, "height"=>540},
|
136
|
+
"medium"=>{"url"=>"https://player.vimeo.com/external/176277723.hd.mp4?s=9eb4ad96f20973877ff433d12751cd792c5a905d&profile_id=174", "width"=>1280, "size"=>27090188, "height"=>720},
|
137
|
+
"tiny"=>{"url"=>"https://player.vimeo.com/external/176277723.sd.mp4?s=a9a3531634d2c42b6e62d10bea241133267589aa&profile_id=164", "width"=>640, "size"=>6193727, "height"=>360}
|
138
|
+
},
|
139
|
+
"tags"=>"beach, holiday, greece",
|
140
|
+
"downloads"=>176636,
|
141
|
+
"likes"=>166,
|
142
|
+
"favorites"=>120,
|
143
|
+
"duration"=>80,
|
144
|
+
"id"=>3998,
|
145
|
+
"user_id"=>2978946,
|
146
|
+
"views"=>40781,
|
147
|
+
"comments"=>63,
|
148
|
+
"userImageURL"=>"https://cdn.pixabay.com/user/2016/07/25/18-27-26-130_250x250.png",
|
149
|
+
"pageURL"=>"https://pixabay.com/videos/id-3998/",
|
150
|
+
"type"=>"film", "user"=>"Rc-Aero-Tech"
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"picture_id"=>"583475757",
|
154
|
+
...
|
155
|
+
},
|
82
156
|
...
|
83
|
-
|
84
|
-
|
157
|
+
],
|
158
|
+
"total"=>5593
|
159
|
+
}
|
85
160
|
```
|
86
161
|
|
87
162
|
## Development
|
data/Rakefile
CHANGED
data/lib/pixabay.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'pixabay/config'
|
2
|
-
require
|
2
|
+
require 'pixabay/version'
|
3
3
|
|
4
4
|
require 'httparty'
|
5
5
|
|
@@ -7,34 +7,40 @@ module Pixabay
|
|
7
7
|
extend Config
|
8
8
|
|
9
9
|
def self.new
|
10
|
-
Pixabay::Client.new(
|
10
|
+
Pixabay::Client.new(key: key, timeout: 10)
|
11
11
|
end
|
12
12
|
|
13
13
|
class Client
|
14
14
|
include HTTParty
|
15
|
-
base_uri
|
15
|
+
base_uri "https://pixabay.com/api"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
image_type: 'all', orientation: 'all', category: nil, min_width: 0,
|
20
|
-
min_height: 0, editors_choice: false, safesearch: false,
|
21
|
-
order: 'popular', page: 1, per_page: 20, callback: nil, pretty: false
|
22
|
-
|
23
|
-
}
|
24
|
-
|
25
|
-
def initialize(api_key: nil, timeout: 10)
|
26
|
-
@api_key = api_key
|
17
|
+
def initialize(key: nil, timeout: 10)
|
18
|
+
@key = key
|
27
19
|
@timeout = timeout
|
28
20
|
end
|
29
21
|
|
30
22
|
def photos(**options)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
default_options = {
|
24
|
+
q: nil, lang: "en", id: nil,
|
25
|
+
response_group: "image_details", image_type: "all", orientation: "all", category: nil,
|
26
|
+
min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
|
27
|
+
order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
|
28
|
+
}
|
29
|
+
|
30
|
+
options = { query: { key: @key }.merge(options) }
|
31
|
+
self.class.get("", options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def videos(**options)
|
35
|
+
default_options = {
|
36
|
+
q: nil, lang: "en", id: nil,
|
37
|
+
video_type: "all", category: nil,
|
38
|
+
min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
|
39
|
+
order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
|
35
40
|
}
|
36
41
|
|
37
|
-
|
42
|
+
options = { query: { key: @key }.merge(options) }
|
43
|
+
self.class.get("/videos", options)
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
data/lib/pixabay/config.rb
CHANGED
data/lib/pixabay/version.rb
CHANGED
data/pixabay.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "httparty", "~> 0.
|
22
|
+
spec.add_dependency "httparty", "~> 0.14.0"
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler",
|
25
|
-
spec.add_development_dependency "rake",
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
26
26
|
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
-
spec.add_development_dependency "rubocop",
|
27
|
+
spec.add_development_dependency "rubocop", "~> 0.49.1"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixabay-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surim Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.14.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.14.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.49.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.49.1
|
83
83
|
description: A ruby wrapper for the pixabay API
|
84
84
|
email:
|
85
85
|
- kimsuelim@gmail.com
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A ruby wrapper for the pixabay API
|