
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Wrapper for Yandex.Webmaster API.
About Yandex.Webmaster
API Documentation
[sudo] gem install yandex-webmaster
Yandex's API uses OAuth for authentication. Luckily, the Yandex::Webmaster gem hides most of the details from you.
If you have never used Webmaster API or you want to change your authentication credentials or your authorization token expired, then you should create new one:
require 'rubygems'
require 'yandex-webmaster'
# Get your API credentials at https://oauth.yandex.ru/
webmaster = Yandex::Webmaster.new(:app_id => 'your_app_id', :app_password => 'your_app_password')
=> #<Yandex::Webmaster::Client>
# Follow the authorization url, you will be redirected to the callback url, specified in your application settings.
webmaster.authorize_url
=> "https://oauth.yandex.ru/authorize?response_type=code&client_id=your_app_id"
# Use authorization code from params to get authorization token
webmaster.authenticate(params[:code])
=> #<Yandex::Webmaster::Client>
# If no error is raised then you are free to use any API method
# Too see what token is now used call for client configuration
token = webmaster.configuration.oauth_token
=> "82af4af2a42e4019bd59a325da0f31d8"
If you want to restore previously used token, it can be easily done too:
require 'rubygems'
require 'yandex-webmaster'
# get your API credentials at https://oauth.yandex.ru/
webmaster = Yandex::Webmaster.new(:oauth_token => 'token')
=> #<Yandex::Webmaster::Client>
To check whether you client is authenticated or not, use authenticated?
method.
# We have already initialized client before.
webmaster.authenticated?
=> true
Get list of sites
Most of Yandex::Webmaster loading methods are lazy, data will be actually loaded only when you really will need it.
webmaster.hosts
=> #<Yandex::Webmaster::ApiFactory>
webmaster.hosts.all
=> #<Array[Yandex::Webmaster::Host]>
# this does not really makes a query to API, list if hosts is cached.
webmaster.hosts.first
=> #<Yandex::Webmaster::Host>
To reload list of hosts, call #host
method with explicitly passed reload
parameter.
# makes call to API and caches list of hosts
webmaster.hosts(true).all
=> #<Array[Yandex::Webmaster::Host]>
# clears cache and makes call to API again.
webmaster.hosts(true).first
=> #<Yandex::Webmaster::Host>
Create site
webmaster.hosts.create('hostname')
=> #<Yandex::Webmaster::Host>
Getting site resources
You can easily find out what API methods are available for selected host.
h = webmaster.hosts.last
=> #<Yandex::Webmaster::Host>
h.resources
=> {:host_information => "https://webmaster.yandex.ru/api/v2/hosts/<host_id>/stats", :verify_host => "https://webmaster.yandex.ru/api/v2/hosts/<host_id>/verify" ... :excluded_urls_history => "https://webmaster.yandex.ru/api/v2/hosts/<host_id>/history/excluded-urls"}
Deleting a site
h = webmaster.hosts.last
=> #<Yandex::Webmaster::Host>
h.delete
=> #<Yandex::Webmaster::Host>
h.deleted?
=> true
Request refreshes following fields in Host:
#name
#verification
#crawling
#virused
#last_access
#tic
#url_count
#index_count
Also request populates the following fields:
#url_errors
#internal_links_count
#links_count
h = webmaster.hosts.last
=> #<Yandex::Webmaster::Host>
# Populates host instance with statistics information
h.load_stats
=> #<Yandex::Webmaster::Host>
h.url_errors
=> 379843
h.internal_links_count
=> 52367
h.links_count
=> 943
Getting a list of Sitemap files
# makes call to API and caches list of sitemaps for the host
webmaster.hosts.first.sitemaps
=> #<Array[Yandex::Webmaster::Hosts::Sitemap]>
To reload list of sitemaps for the host, call #host
method with explicitly passed reload
parameter.
webmaster.hosts.first.sitemaps(true)
=> #<Array[Yandex::Webmaster::Hosts::Sitemap]>
Getting information about a site's Sitemap file
To load detailed information about Sitemap file use #load_details
method.
sitemap = webmaster.hosts.first.sitemaps.first
=> #<Yandex::Webmaster::Hosts::Sitemap>
sitemap.load_details
=> #<Yandex::Webmaster::Hosts::Sitemap>
When details are loaded you can see Sitemap info.
sitemap.latest_info
=> #<Yandex::Webmaster::Hosts::SitemapInfo>
sitemap.in_search_info
=> #<Yandex::Webmaster::Hosts::SitemapInfo>
Removing a Sitemap
sitemap = webmaster.hosts.first.sitemaps.first
=> #<Yandex::Webmaster::Hosts::Sitemap>
sitemap.delete
=> #<Yandex::Webmaster::Host>
sitemap.deleted?
=> true
Basic verification information is loaded with Host load.
For verified sites:
h = webmaster.hosts.last
=> #<Yandex::Webmaster::Host>
h.verification
#<Yandex::Webmaster::Hosts::Verification state: "verified">
And for not verified sites:
h = webmaster.hosts.create('http://www.tver.ru')
h.verification
=> #<Yandex::Webmaster::Hosts::Verification state: "never_verified">
Webmaster is maintained by JetRockets.
Contributors:
It is free software, and may be redistributed under the terms specified in the LICENSE file.
FAQs
Unknown package
We found that yandex-webmaster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.