Hi, I’ve been trying to use the package searchtweets-v2 without success.

When I type:

from searchtweets import load_credentials

load_credentials(filename="./search_tweets_creds_example.yaml",
                 yaml_key="search_tweets_v2_example",
                 env_overwrite=False)

The output says:

cannot read file ./search_tweets_creds_example.yaml
Error parsing YAML file; searching for valid environment variables

Any help please?

1 Like

Does the file search_tweets_creds_example.yaml definitely exist in the same folder as the script is executing in? Double check that the file isn’t actually named search_tweets_creds_example.yaml.txt like it does sometimes on Windows.

Is this file valid YAML? (whitespace is syntax in YAML and goes wrong often)

Also the yaml top level key should be search_tweets_v2_example so your YAML file should look like:

search_tweets_v2_example:
  endpoint: "https://api.twitter.com/2/tweets/search/recent"
  bearer_token: "AAA.....zzz"
1 Like