This SDK makes using the Getty Images API easy. It handles credential management, makes HTTP requests and is written with a fluent style in mind. The API Documentation is located on Github.
The SDK is published to the public Nuget package repository.
Open the package manager and add the package to your project:
The SDK currently supports:
- Searching for images
- Getting image metadata
- Creating download URLs
The SDK supports async operations, however it can also be used synchonously, such as when running in a console application:
var connect = ConnectSdk.GetConnectSdkWithClientCredentials("my_api_key", "my_api_secret");
var searchResult = connect.Search()
.Images()
.Editorial()
.WithEditorialSegment(EditorialSegment.News)
.WithPhrase("all vocabulary")
.WithSortOrder("newest")
.ExecuteAsync()
.Result;
foreach (var image in searchResult.images)
{
Console.WriteLine("Title: {0} \r\nId: {1}", image.title, image.id);
}
Results are returned as dynamic
. Visit the API Interactive Documentation to learn more about available parameters and to see what the response object look like.
This is only necessary if you would like to contribute to the project. Otherwise, use the Nuget Package
- You have Visual Studio 2013 Update 4
- You have Git installed
- Git for Windows
- If you are using Cygwin, use the Cygwin Package Installer to install Git
- You have the SpecFlow extension installed in Visual Studio
The API team at Getty Images uses Behavior Driven Development (BDD). We think it's a great way to develop software and want to spread the word. The test project contains scenarios written in the Gherkin language which are bound to code using SpecFlow.
The Git repository contains a submodule which requires some special handling to get setup properly. This is because we share our scenario files across all our SDKs.
Open a console window (Command Prompt, PowerShell or Bash) and issue the following commands to clone the Git repository:
git clone git@github.com:gettyimages/connect_sdk_csharp.git
pushd connect_sdk_csharp
git submodule update --init
.\build.cmd
./build.sh
The tests expect credentials to be stored in environment variables.
- ConnectSDK_ApiKey: API key assigned when you registered
- ConnectSDK_ApiSecret: API secret assigned when you registered
- ConnectSDK_UserName: a Getty Images user. Create one at the Getty Images website.
- ConnectSDK_UserPassword: Getty Images user's password
Note: If you don't have user account credentials, some of the tests will fail. That's OK!
Once this is complete, you can open the solution in Visual Studio:
- Open the ConnectSdk.sln file.
- Build the solution.
- Tests can be run using:
- ReSharper Unit Test Explorer
- NUnit - You may need to install the NUnit Test Adapter
- Note: Running all tests at once can occasionally result in the error "GettyImages.Connect.OverQpsException : Exception of type 'GettyImages.Connect.OverQpsException' was thrown.". Please run tests individually if you encounter this error and the tests should run properly.