.NET client for Twingly Search API (previously known as Twingly Analytics API). Twingly is a blog search service that provides a searchable API.
Install via NuGet
Install-Package Twingly.Search.Client
- [Required] Set API key in the appSettings section of your config file:
<appSettings>
<add key="TWINGLY_SEARCH_KEY" value="YOUR_KEY_GOES_HERE"/>
</appSettings>
- [Optional] Set request timeout. The default timeout value is 10 seconds.
<appSettings>
<add key="TWINGLY_TIMEOUT_MS" value="REQUEST_TIMEOUT_IN_MILLISECONDS"/>
</appSettings>
- Alternatively: Set these settings in the environment variables. The settings are first read from configuration, then from the environment variables.
Fetch docs about "Slack" published since yesterday. Limit results to 10 posts.
Query theQuery = QueryBuilder.Create("Slack page-size:10")
.StartTime(DateTime.UtcNow.Subtract(TimeSpan.FromDays(1)))
.Build();
ITwinglySearchClient client = new TwinglySearchClient();
// identify your company by setting the user agent.
client.UserAgent = "Willy Wonka Chocolate Factory";
QueryResult matchingDocs = client.Query(theQuery);
foreach (var post in matchingDocs.Posts)
{
Console.WriteLine("Title: '{0}', Date: '{1}', Url: '{2}'",
post.Title, post.Published, post.Url);
}
To learn more about the features of this client, check out the example code in Twingly.Search.Samples.
Exceptions are organized into the following hierachy:
RequestException
- base class for any Twingly-related exceptionAuthException
- thrown when the provided key does not have access to the APIQueryException
- thrown when there is something wrong with the parameters or the query sent to the APIServerException
- thrown when service is not available
ApiKeyNotConfiguredException
- thrown when an API key was not found in the config file
- API key, sign up via twingly.com to get one
- .NET Framework v4.5.2 or Mono 5.0
It is possible to check the code coverage by using the tool OpenCover.
Prerequisites:
- Install the OpenCover binary or get it via NuGet
- Install the Visual Studio extension
To use the tool:
- Open the window
OpenCover Test Explorer
- Group by
Project
- Right-click
Twingly,Search.Tests
and selectCover with OpenCover
- Open the window
OpenCover Results
to inspect the outcome
Note: The first time you use the Visual Studio extension you will need to give it the path to the OpenCover binary which is typically installed at: %localappdata%\Apps\OpenCover\OpenCover.Console.exe
A NuGet package is automatically generated on each build, using handy automation scripts by Daniel Schroeder.
- Bump the version and update the release notes in
Twingly.Search.Client\_CreateNewNuGetPackage\Config.ps1
- Bump the
AssemblyVersion
andAssemblyFileVersion
inTwingly.Search.Client\Properties\AssemblyInfo.cs
- Commit the changes
- Tag the current commit with the same version number and push it
- Build the project
Twingly.Search.Client
in release mode
- The
.nupkg
file is placed in theTwingly.Search.Client\bin\Release
directory
- Run
Twingly.Search.Client\_CreateNewNuGetPackage\RunMeToUploadNuGetPackage.cmd
- Point it to the
.nupkg
file - Enter your API key
The MIT License (MIT)
Copyright (c) 2016 Andrey Mironoff, Twingly AB
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.