{"id":25317340,"url":"https://github.com/xebia-functional/appsly-android-rest","last_synced_at":"2025-10-28T21:30:42.364Z","repository":{"id":4762150,"uuid":"5912634","full_name":"xebia-functional/appsly-android-rest","owner":"xebia-functional","description":"An Android client library for RESTful based web services.","archived":false,"fork":false,"pushed_at":"2015-11-30T09:53:20.000Z","size":3503,"stargazers_count":209,"open_issues_count":7,"forks_count":51,"subscribers_count":79,"default_branch":"master","last_synced_at":"2024-05-17T15:06:10.840Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xebia-functional.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-22T11:48:40.000Z","updated_at":"2024-04-01T03:58:48.000Z","dependencies_parsed_at":"2022-08-06T17:31:08.467Z","dependency_job_id":null,"html_url":"https://github.com/xebia-functional/appsly-android-rest","commit_stats":null,"previous_names":["47degrees/appsly-android-rest"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Fappsly-android-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Fappsly-android-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Fappsly-android-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Fappsly-android-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xebia-functional","download_url":"https://codeload.github.com/xebia-functional/appsly-android-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238722711,"owners_count":19519801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-13T19:37:18.939Z","updated_at":"2025-10-28T21:30:41.771Z","avatar_url":"https://github.com/xebia-functional.png","language":"Java","funding_links":[],"categories":["网络编程"],"sub_categories":["Spring Cloud框架"],"readme":"[![Build Status](https://clinker.47deg.com/desktop/plugin/public/status/appsly-android-rest.png?branch=master)](https://clinker.47deg.com/jenkins/view/Appsly/job/appsly-android-rest/)\n\nTHIS PROJECT IS DISCONTINUED — USE AT YOUR OWN RISK\n\nIt has been a fun and great project but it's time for us to move on. Check out our recent work that we are doing with Scala on Android. http://47deg.github.io/translate-bubble-android/ and follow us on Github and Twitter for new and exciting open source projects. Thanks for your continuing support. If you wish to take on maintenance of this library please contact us through the issue tracker.\n\n# Appsly Android REST\n\nAsync Android client library for [RESTful](http://en.wikipedia.org/wiki/Representational_state_transfer) services.\n\n# Introduction\n\nAppsly Android REST (AKA RESTrung) is a annotation based client library to connect to RESTful services on Android with an emphasis in simplicity and performance that automatically handles the\nimplementation for most common REST use cases. Easily handle GET, POST, PUT and DELETE requests in an elegant way.\n\n# Getting Started\n\nAppsly Android REST allows you to declare your operations as annotated Java methods on a Java interface that you don't have to implement yourself.\nThe interface is used to generate a automatically a proxy instance that does the actual work and taking care of all the implementation details.\n\nLet's say we were implementing the Open Weather Forecast API to get the weather forecast for the [47 Degrees](http://47deg.com) office in Ballard, Seattle.\nWe would need to fetch json from this http endpoint and convert it's response to our Java model.\nThis is how we'd do it.\n\nhttp://api.openweathermap.org/data/2.5/weather?lat=47.663267\u0026lon=-122.384187\n\n```java\n\n@RestService\npublic interface OpenWeatherAPI {\n\n    @GET(\"/weather\")\n    void getForecast(@QueryParam(\"lat\") double latitude, @QueryParam(\"lon\") double longitude, Callback\u003cForecastResponse\u003e callback);\n\n}\n\n```\n\n```java\n\npublic class ForecastResponse {\n\n    private String name;\n\n    ... getters and setters ...\n\n}\n\n```\n\n```java\n\nRestClient client = RestClientFactory.defaultClient(context);\nOpenWeatherAPI api = RestServiceFactory.getService(baseUrl, OpenWeatherAPI.class, client);\n// hold on to the api object for the lifecycle of your app or activity context\n\n```\n\n```java\n// somewhere else in your code\n\napi.getForecast(47.663267, -122.384187, new Callback\u003cForecastResponse\u003e() {\n\n    @Override\n    public void onResponse(Response\u003cForecastResponse\u003e response) {\n        // This will be invoke in the UI thread after serialization with your objects ready to use\n    }\n\n});\n\n```\n\n# Download\n\n## Gradle  Dependency\n\nAppsly Android REST may be automatically imported into your project if you already use the [Android Gradle Build System](http://tools.android.com/tech-docs/new-build-system/user-guide). Just declare Appsly Android REST as a gradle dependency.\nIf you wish to always use the latest unstable snapshots, add the Clinker Snapshots repository where the Appsly Android REST snapshot artifacts are being deployed.\nAppsly Android REST official releases will be made available at Clinker and Maven Central as they become available\n\n\n**SNAPSHOTS**\n\n\n*Gradle*\n\n```groovy\n\nmaven { url 'http://clinker.47deg.com/nexus/content/groups/public' }\n\ndependencies {\n    compile ('ly.apps:android-rest:1.2.1-SNAPSHOT@aar') {\n        transitive = true\n        changing = true\n    }\n}\n```\n\n# Configuration\n\n## Annotations\n\n### @RestService\n\nIndicates an interface is to be proxied and its methods mapped to rest operations\n\n```java\n@RestService\npublic interface MyAwesomeService {\n...\n}\n```\n\n### @GET\n\nIndicates a method is mapped to an HTTP GET request\n\n```java\n@GET(\"/resource/{id}\")\nvoid fetch(@Path(\"id\") String id);\n```\n\n### @POST\n\nIndicates a method is mapped to an HTTP POST request\n\n```java\n@POST(\"/resource\")\nvoid add(@Body MyRequest request);\n```\n\n### @PUT\n\nIndicates a method is mapped to an HTTP PUT request\n\n```java\n@PUT(\"/resource\")\nvoid fetch(@Body MyRequest request);\n```\n\n### @DELETE\n\nIndicates a method is mapped to an HTTP DELETE request\n\n```java\n@DELETE(\"/resource/{id}\")\nvoid remove(@Path(\"id\") String id);\n```\n\n### @Path\n\nIndicates a method arg is a path parameter in the url\n\n```java\n@GET(\"/resource/{id}\")\nvoid fetc(@Path(\"id\") String id);\n```\n\n### @QueryParam\n\nIndicates a method arg is a query parameter in the url query string\n\n```java\n@GET(\"/resource/list\")\nvoid list(@QueryParam(\"limit\") int limit);\n```\n\n### @QueryParams\n\nIndicates a method arg is a bean including properties that will be mapped to query parameters in the url query string\n\n```java\n@GET(\"/resource/list\")\nvoid list(@QueryParams PaginationInfo paginationInfo);\n```\n\n### @FormField\n\nIndicates a method arg is mapped to a post parameter\n\n```java\n@POST(\"/account\")\nvoid update(@FormField String username);\n```\n\n### @FormData\n\nIndicates a method arg is a bean including properties that will be mapped to post parameters\n\n```java\n@POST(\"/account/settings\")\nvoid updateSettings(@FormData AccountSettings settings);\n```\n\n### @Header\n\nIndicates a method arg should be sent as a request header\n\n```java\n@GET(\"/resource/list\")\nvoid list(@Header(\"X-AuthToken\") String token);\n```\n\n### @Cached\n\nIndicates a method is mapped to a REST operation whose response may be cached.\nFor more details on caching see [Cache](#Cache)\n\n```java\n@Cached\n@GET(\"/resource/list\")\nvoid list();\n```\n\n## Cache\n\nAppsly Android REST is built with performance and flexibility in mind.\nIt includes a cache mechanism to help with fast retrieval, caching and reusing of serialized responses.\n\nTo mark a method as @Cached you can simply annotate it providing the optional type of cache and time to live for the cached serialized response.\n\nIn the following example the Forecast information will be loaded from the cache not hitting the server if requested within 10 minutes of the first time it was requested.\nAfter the 10 minutes pass the cache will be invalidated and reloaded. This means your users will not have to wait for your Activity to load and connect to the internet each\ntime a user visits the weather forecast for that location. Think battery saving on your application and a better end user experience.\n\n```java\n\n@GET(\"/weather\")\n@Cached(policy = CachePolicy.ENABLED, timeToLive = 10 * 60 * 1000)\nvoid getForecast(@QueryParam(\"lat\") double latitude, @QueryParam(\"lon\") double longitude, Callback\u003cForecastResponse\u003e callback);\n\n```\n\n### Policies\n\nThe cache policies available are:\n\n* NEVER - Never use the cache.\n* LOAD_IF_OFFLINE - Load from the cache when the app is offline.\n* LOAD_ON_ERROR - Load from cache if there is an error.\n* ENABLED - Load always from the cache if available.\n* LOAD_IF_TIMEOUT - Load from the cache when the request times out.\n* NETWORK_ENABLED - Load from the cache then refresh the cache with a network call (may call onResponse in the callback twice)\n\nThe NETWORK_ENABLED policy is particularly useful for use cases where you may display stale data on a Activity or Fragment but immediately refresh it\nif the content has changed since it was last requested.\n\n## Serialization\n\nAppsly Android REST ships with the popular library [Jackson]() for serialization and deserialization by default but provides\noverridable service definitions to allow for customization or plugin in different implementations\n\n### Path \u0026amp; Query Params Converter\n\nThe query and path param converter serializes method args into the final url and query string used to perform the\nrequest.\n\nTo provide a custom implementation override [ly.apps.android.rest.converters.QueryParamsConverter]() and construct the RestClient\nby passing it as argument.\n\n```java\nQueryParamsConverter customQueryParamsConverter = new MyCustomQueryParamsConverter();\nRestClient client = new DefaultRestClientImpl(httpClient, customQueryParamsConverter, bodyConverter);\n```\n\n### Request and Response Body Converters\n\nThe Body Converter serializes and deserializes Beans and Objects into JSON, Post params, etc. both for Request and Response bodies\n\nTo provide a custom implementation override [ly.apps.android.rest.converters.BodyConverter]() and construct the RestClient\nby passing it as argument to the DelegatingConverterService which is also the default body converter.\nThe DelegatingConverterService evaluates all added converter in orders looking for candidates to handle the body.\n\n```java\nDelegatingConverterService bodyConverter = new DelegatingConverterService(){{\n    addConverter(new MyCustomBodyConverter());\n    addConverter(new JacksonBodyConverter());\n    addConverter(new JacksonHttpFormValuesConverter());\n}};\nRestClient client = new DefaultRestClientImpl(httpClient, queryParamsConverter, bodyConverter);\n```\n\n## Async http client\n\nAppsly Android REST uses the popular [AsyncHttpClient]() under the hood.\n\nYou may also provide customization to the http client such as providing default headers, enabling a lower level http response cache, etc.\n\nE.g. To customize the http client configuration you may simply pass your customized instance to the RestClient.\nIn the case below, the default in the lib, the lower level http client [http response](http://developer.android.com/reference/org/apache/http/HttpResponse.html) cache is enabled.\nAlso the serialized entity cache is enabled as well and the Persistent Cache Manager based on [LRUDiskCache]\n\n```java\nRestClient client = new DefaultRestClientImpl(\n    new CacheAwareHttpClient(new ContextPersistentCacheManager(context)) {{\n        enableHttpResponseCache(10 * 1024 * 1024, new File(context.getCacheDir(), \"android-rest-http\"));\n    }},\n    new JacksonQueryParamsConverter(),\n    new DelegatingConverterService(){{\n        addConverter(new JacksonBodyConverter());\n        addConverter(new JacksonHttpFormValuesConverter());\n    }}\n);\n```\n\n## Request \u0026amp; Response Lifecycle\n\nCallback are instances of the [ResponseHandlerInterface]() and as such they allow for overriding the response lifecycle methods\nto get progress notifications, intercepting serialization at a lower level, manipulating headers, results and failures.\n\n\n# Credits\n\nAppsly Android REST is a library maintained by the [47 Degrees] team and part of the OS Framework [apps.ly Reaktor](http://reaktor.apps.ly)\nAppsly Android REST is inspired by other libs and projects such as [Android Async Http Client](), [Jackson](Jackson), [Retrofit](), [LRUDiskCache](), etc.\n\n# Continuous Integration\n\nCI and Artifact Repository hosted in ClinkerHQ.com \n\n[![ClinkerHQ][1]][2]\n\n# License\n\nCopyright (C) 2014 47 Degrees, LLC\nhttp://47deg.com\nhello@47deg.com\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[1]: http://dl.clinkerhq.com/assets/badge/clinker-badge_125x125.png\n[2]: http://clinkerhq.com\n[4]: https://clinker.47deg.com/jenkins/view/Appsly/job/appsly-android-rest/\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxebia-functional%2Fappsly-android-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxebia-functional%2Fappsly-android-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxebia-functional%2Fappsly-android-rest/lists"}