similarweb-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +40 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/similarweb.rb +6 -0
- data/lib/similarweb/client.rb +24 -0
- data/lib/similarweb/client/total_traffic_and_engagement.rb +18 -0
- data/lib/similarweb/version.rb +3 -0
- data/similarweb-api.gemspec +40 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e4b723bcbe863069ef0305900a3eb98a824e18c
|
4
|
+
data.tar.gz: 6c4d1a1f8b495a7ea209c2c9f3015fc913a01ced
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86013e70a8cca25106427e83ddbd0fe9a80f5ecbf2e50e343870032efe53d1caba1f3ef94be816e658cf8ef3b6a00f8f5e893e9b804eb7b145cafd9af82a401c
|
7
|
+
data.tar.gz: 67157abcd2b8bffe2841b590b3a988758502c67d5378c67e0d0a9b0367e5b389565af55f11a4c0b52d1f08f702c44430b11b0ea9c75ffdf23683047b11018713
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
similarweb-api (0.0.2)
|
5
|
+
dry-configurable
|
6
|
+
faraday
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (9.1.0)
|
12
|
+
coderay (1.1.1)
|
13
|
+
concurrent-ruby (1.0.5)
|
14
|
+
dry-configurable (0.7.0)
|
15
|
+
concurrent-ruby (~> 1.0)
|
16
|
+
faraday (0.14.0)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
method_source (0.8.2)
|
19
|
+
multipart-post (2.0.0)
|
20
|
+
pry (0.10.4)
|
21
|
+
coderay (~> 1.1.0)
|
22
|
+
method_source (~> 0.8.1)
|
23
|
+
slop (~> 3.4)
|
24
|
+
pry-byebug (3.4.2)
|
25
|
+
byebug (~> 9.0)
|
26
|
+
pry (~> 0.10)
|
27
|
+
rake (10.5.0)
|
28
|
+
slop (3.6.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.16)
|
35
|
+
pry-byebug
|
36
|
+
rake (~> 10.0)
|
37
|
+
similarweb-api!
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Similarweb::Api
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/similarweb/api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'similarweb-api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install similarweb-api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/similarweb-api.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "similarweb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/similarweb.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'dry-configurable'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
require_relative 'client/total_traffic_and_engagement'
|
5
|
+
|
6
|
+
module Similarweb
|
7
|
+
class Client
|
8
|
+
extend Dry::Configurable
|
9
|
+
extend TotalTrafficAndEngagement
|
10
|
+
setting :api_key
|
11
|
+
setting :url, 'https://api.similarweb.com/v1/website/'
|
12
|
+
setting :start_date, Date.today.prev_month.strftime('%Y-%m')
|
13
|
+
setting :end_date, Date.today.prev_month.strftime('%Y-%m')
|
14
|
+
setting :granularity, :monthly
|
15
|
+
setting :main_domain_only, false
|
16
|
+
|
17
|
+
def self.make_request!(url, params)
|
18
|
+
merged_params = Similarweb::Client.config.to_h.merge(params)
|
19
|
+
http_client = Faraday.new(url: Similarweb::Client.config.url, params: merged_params)
|
20
|
+
JSON(http_client.get(url).body)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Similarweb
|
2
|
+
module TotalTrafficAndEngagement
|
3
|
+
def visits(domain, params = {})
|
4
|
+
url = "#{domain}/total-traffic-and-engagement/visits"
|
5
|
+
self.make_request!(url, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def average_visit_duration(domain, params = {})
|
9
|
+
url = "#{domain}/total-traffic-and-engagement/average-visit-duration"
|
10
|
+
self.make_request!(url, params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def pages_per_visit(domain, params = {})
|
14
|
+
url = "#{domain}/total-traffic-and-engagement/pages-per-visit"
|
15
|
+
self.make_request!(url, params)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "similarweb/version"
|
4
|
+
# require "similarweb"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "similarweb-api"
|
8
|
+
spec.version = Similarweb::VERSION
|
9
|
+
spec.authors = ["Aleksey Yudin"]
|
10
|
+
spec.email = ["qaa12work@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple ruby wrapper for SimilarWeb API }
|
13
|
+
spec.description = %q{Simple ruby wrapper for SimilarWeb API }
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.required_ruby_version = '>= 2.1'
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_dependency "dry-configurable"
|
37
|
+
spec.add_development_dependency "pry-byebug"
|
38
|
+
spec.add_runtime_dependency "faraday"
|
39
|
+
# gem.add_runtime_dependency("json", ">= 1.8")
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: similarweb-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleksey Yudin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-configurable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: 'Simple ruby wrapper for SimilarWeb API '
|
84
|
+
email:
|
85
|
+
- qaa12work@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- lib/similarweb.rb
|
98
|
+
- lib/similarweb/client.rb
|
99
|
+
- lib/similarweb/client/total_traffic_and_engagement.rb
|
100
|
+
- lib/similarweb/version.rb
|
101
|
+
- similarweb-api.gemspec
|
102
|
+
homepage: ''
|
103
|
+
licenses: []
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '2.1'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.6.12
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Simple ruby wrapper for SimilarWeb API
|
125
|
+
test_files: []
|