brandwatchltd / api_sdk Goto Github PK
View Code? Open in Web Editor NEWSDK for the Brandwatch API
License: MIT License
SDK for the Brandwatch API
License: MIT License
When multiple threads creates BWProject, system may fail to open the token file. This exception is explicitly discarded (bwproject.py#L104), which in turn causing an UnboundLocalError at run time.
Add a rename() method in BWResources and remove the new_name handling in each subclass's _fill_data() mehod.
Let's add support for the "become" functionality in the API:
`params = {
"username": other_user,
"grant_type": "application-become",
"client_id": "brandwatch-application-client",
}
at = requests.post("http://newapi.brandwatch.com/'oauth/token/?access_token=" + bw_admin_token, params=params)
token_for_client_account = at.json()['access_token’]`
After Downloading the data ,I could see that the twitter data is empty under fullText ,I cant see any data under that domain twitter
The old endpoint will remain for a while, but it'll be better to use the new endpoint
POST /{projectId}/bulkactions/rule/{ruleId}
API tokens should be passed in the HTTP header rather than as URL params. In theory this should just involve modifying BWUser.bare_request()
in a fairly trivial way.
I am trying to update the Search Terms for multiple existing Query Names in one of my project using the SDK in Python. When I use the upload()
or upload_all()
from BWQueries the search terms get updated but the baclfill_date
is not getting updated.
I am setting below values:
query_list = list({'name': 'CONVERSEON-TEST-SDK', 'includedTerms': 'author:(
770002)', 'backfill_date': '2017-07-01'},
{'name': 'CONVERSEON-TEST-SDK2', 'includedTerms': 'author:(318808889
OR 319990802)', 'backfill_date': '2017-07-01'})
queries.upload_all(query_list)
If I go into the BWResource class and log the response of upload_all(), it shows me that it has updated: ‘unlimitedHistoricalData’: {‘backfillMinDate’: ‘2017-07-01T00:00:00.000+0000’, ‘unlimitedHistoricalDataEnabled’: False}}
But in the frontend it always says August. Below is the screenshot:
Hello,
I have the question when calling the API the JSON including the data which the value is zero or negative for some dimensions. For example, when I use the below endpoint to retrieve the aggregated data.
https://api.brandwatch.com/projects/xxxxxx/data/forumPosts/languages/days?queryId=111&startDate=2019-10-04&endDate=2019-10-05
Please see the example JSON data, the value is zero.
{"dimension1":"languages","dimension2":"days","aggregate":"forumPosts","results":[{"id":"en","name":"English","data":{},"values":[{"id":"2019-10-04T00:00:00.000+0000","name":"2019-10-04 00:00:00.0","data":{},"value":0}]}]}
Is it possible to filter the zero and negative values with some parameters?
Thank you,
Yonghe
But behavior seems to indicate that only the sub-categories and categories of one dictionary element are applied to the mention. Can reproduce if desired.
For some reason we are sleeping for half a second before each request. I can't think why we would want to do that.
https://github.com/BrandwatchLtd/api_sdk/blob/master/bwproject.py#L166
I am getting the following error when using the function get_mentions from the BWQueries class in v.1.0.6:
line 181, in get_mentions next_mentions = self.get_mentions_page(params, 0) AttributeError: 'BWQueries' object has no attribute 'get_mentions_page'
I couldn't quite figure out what causes the error but when I used the previous version of bwresources.py (that has been updated on 5. July by @pwsiegel) it works.
I am using the simplest "get_mentions" call (only name, startDate, EndDate and no filters).
This logic centralizes authentication in the BWUser class, and mimics the lookup logic of other classes in BWQueries, etc.
Concretely improves the workflow for users that want to created a BWUser instance and access multiple projects in a single session.
I was wondering whether it would be possible of having the option to feed in a list of start dates (and potentially end dates) in to a "get_mentions" call.
As I understood, at the moment I can feed in a list of names but they will all have the same start and end date. For the task I am trying to achieve each query would have a different start date.
For now I will use a loop for each query but was wondering whether the performance would be better when submitting fewer requests.
at least on backwards compatability issue between github v and pypi v:
.num_mentions returns dict in 1.2.2
.num_mentions returns int in 1.1.2
Consider a call of the form
BWQueries().get_chart(name='My Query', startDate='YYYY-MM-DD', x_axis='days', y_axis='volume', breakdown_by='tags', dim2Args=['first_tag, 'second_tag'])
The SDK makes a call which looks like:
https://api.brandwatch.com/projects/<project id>/data/volume/days/tags?queryId=<query id>&startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&dim2Args=<tag id>&dim2Args=<tag id>&access_token=<token>
But this returns a response with all data and values fields empty. The reason is that the API expects tag names instead of tag id's; the following call gives the desired result:
https://api.brandwatch.com/projects/<project id>/data/volume/days/tags?queryId=<query id>&startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&dim2Args=first_tag&dim2Args=second_tag&access_token=<token>
I think the same issue came up when formulating get_mentions
requests with tag filters; for some mysterious reason the API expects category ID's but tag names. 🤷♂️
Add ability to filter mentions call by a boolean string. Warning: test first to ensure that it doesn't put too much strain on the system (i.e. test extra time it takes)
Right now we parse queries by where there is a comma - but what if the query name has a comma in it?
Hello,
I went through the DEMO and I thought I could download all queries in a group, but in practice I got this error:
('No valid queries ids could be extracted', 'MyGroup')
In bwresources.py, it says:
def get_mention(self, **kwargs): Retrieves a single mention by url or resource id. This is ONLY a valid function for queries (not groups), which is why it isn't split out into bwdata.
Well, is there a way to download the data from all queries in a group in one call? Or at least interact with a list of queries?
Thanks!
I came across an issue when I use the token_path instead of the password to request my project:
BWProject(username=YOUR_ACCOUNT, project=YOUR_PROJECT)
When at the beginning I used my username and password, the tokens.txt was generated with the username in lowercase (_read_auth_file).
On the other hand, my username contains capital letters, meaning my user´s json will be returned with these capital letters in the username field, so the _test_auth() method will fail in bwproject.py.
I can think of ways to get around it by making it case sensitive, but I would appreciate some suggestions.
Many thanks in advance!
Hello,
I installed the bwapi
package in my Python3 environment. Example:
(bw) alexis@linux:~/brandwatch$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
bwapi (3.2.0)
certifi (2018.11.29)
chardet (3.0.4)
idna (2.8)
pip (9.0.1)
pkg-resources (0.0.0)
requests (2.21.0)
setuptools (39.0.1)
urllib3 (1.24.1)
However, when I run the following code coming from DEMO.ipynb
it tells me that I am missing the package authenticate
.
(bw) alexis@linux:~/brandwatch$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from authenticate import authenticate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'authenticate'
Could you please tell me what am I missing?
Thanks
Alexis
In the DashBoard UI, we can easy to filter the categories by using the field: Filter By Category and Exclude Category , but in the example for API, i can see only parentCategory and Category (maybe they are representing for the field: Filter By Category). Where can i put Exclude Category in the API?
Thanks
In
Line 53 in 2a9457f
The list of mentions returned by BWMentionsResources.get_mentions()
may contain duplicates if new mentions are added during multi-page calls. Perhaps the best solution is to implement paging by modifying end dates rather than using the API's native paging support.
Let's add support for the "become" functionality in the API:
params = {
"username": other_user,
"grant_type": "application-become",
"client_id": "brandwatch-application-client",
}
at = requests.post("http://newapi.brandwatch.com/oauth/token/?access_token=" + bw_admin_token, params=params)
token_for_client_account = at.json()['access_token’]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.