Stilavia/zalando-api


Java Client for Zalando's API

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.Stilavia:zalando-api:'
	}
	dependencies {
		implementation("com.github.Stilavia:zalando-api:")
	}
	<dependency>
	    <groupId>com.github.Stilavia</groupId>
	    <artifactId>zalando-api</artifactId>
	    <version></version>
	</dependency>

                            
    libraryDependencies += "com.github.Stilavia" % "zalando-api" % ""
        
        

                            
    :dependencies [[com.github.Stilavia/zalando-api ""]]
        
        

Readme


Java Client of Zalando's API

This project is a Java client for the public Zalando's API. The client is based on a fluent java api that maps the cascade of methods to the Zalando's api endpoints. For example:

PaginableResult<Brand> brands = zalandoApi.brands().pageSize(10).name("nike").get();

Maps to the request:

curl -XGET 'https://api.zalando.com/brands?pageSize=10&name=nike'

Compilation

mvn compile

Usage

First you have to install the maven artifact locally

mvn install

Then add the artifact to your dependencies:

<dependencies>
    ...
    <dependency>
        <groupId>org.stilavia</groupId>
        <artifactId>zalando-api</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    ...
</dependencies>

And then the usage is as follows:

public static void main(String[] args) throws IOException, URISyntaxException {
    ZalandoApi zalandoApi = new ZalandoApiBuilder()
                                .setDomain(Domain.es_ES)
                                .enableHttps()
                                .build();
    PaginableResult<Category> categories = zalandoApi.categories().pageSize(20).get();
    System.out.println(categories);
    Article article = zalandoApi.articles("TF121C066-A11").get();
    System.out.println(article);
}

To use this client in a Spring application consider the following setup:

@Configuration
public class ZalandoApiConfiguration {

    @Bean
    public ZalandoApi zalandoApi(@Value("${zalando-api.domain:es_ES}") Domain domain) {
        return new ZalandoApiBuilder()
                    .setDomain(domain)
                    .enableHttps()
                    .build();
    }
    
}

Dependencies

This API depends on three other popular modules:

  • org.apache.httpcomponents artifact httpclient version 4.5

  • com.google.guava artifact guava version 18

  • org.codehaus.jackson artifact jackson-mapper-asl version 1.9.13

Since all these artifacts are pretty popular take with care the possible artifact's version conflicts. If you are going to use this software under an Android device consider the httpclient issues.