Expand description
§wordstat-rs
This crate makes it easy to interact with Yandex Direct API for getting statistics about keyword searches from Wordstat service.
§Example
To start using the library you should first create the client the following way:
let client = Client::new("token", "api_url");
To get the list of available regions do the following:
let regions = get_regions(&client).await.unwrap();
This returns a Result enum, containing a vector of regions
To start generating a report you should craete a ReportRequest and then call create_report function.
let request = ReportRequest::new()
.add_phrase("rust lang").unwrap()
.add_geo(101);
let report_id = create_report(&client, &request).await.unwrap();
To check the list of available reports and their statuses you can use:
let report_list = get_report_list(&client).await;
This returns a Result enum, containing a vector of report statuses
If the report is ready, you can get it using:
let report = get_reports(&client, report_id).await;
This returns a Result enum, containing a vector of report entries (one per keyphrase in the ReportRequest).
To delete a report you should use:
delete_report(&client, 11053065).await.unwrap();
§Usage notes
While using the library keep in mind:
- One ReportRequest can contain up to 10 keyphrases
- The server stores up to five reports simultaneously, so you should delete the report once you have downloaded its data
- Geo is optional when creating a ReportRequest
§API URLs
API version 4 should be used The API URL is https://api.direct.yandex.ru/v4/json/. If your token is for the API sandbox you should use https://api-sandbox.direct.yandex.ru/v4/json/ as the URL.
§Getting the API token
- Create an application that will be using the Yandex Direct API here
- Recieve access to the API by filing the form here
- Turn on the sandbox mode here
- Get the token by authorizing in your app by following this link:
https://oauth.yandex.ru/authorize?response_type=token&client_id=[app_client_id]
Don’t forget to replace the
app_client_id
with the client_id of your app.
Re-exports§
pub use client::Client;
pub use create_report::ReportRequest;
pub use create_report::create_report;
pub use delete_report::delete_report;
pub use get_report::ReportEntry;
pub use get_report::WordstatItem;
pub use get_report::get_report;
pub use region::Region;
pub use region::get_regions;
pub use report_list::ReportStatus;
pub use report_list::StatusCode;
pub use report_list::get_report_list;