Connect with Redis client API libraries

Connect your application to a Redis database and try an example

Use the Redis client libraries to connect to Redis servers from your own code. We document the following client libraries for eight main languages:

Language Client name Docs Supported
Python redis-py redis-py guide Yes
Python RedisVL RedisVL guide Yes
C#/.NET NRedisStack NRedisStack guide Yes
JavaScript node-redis node-redis guide Yes
JavaScript ioredis ioredis guide Yes
Java Jedis Jedis guide Yes
Java Lettuce Lettuce guide Yes
Go go-redis go-redis guide Yes
PHP Predis Predis guide Best effort *
C hiredis hiredis guide Yes
Rust redis-rs redis-rs guide Best effort *
Note:
* Redis does not provide official support for third-party client libraries. However, we contribute new features, offer guidance, and collaborate with the community on a best-effort basis to help ensure these libraries remain reliable and up-to-date.

We also provide several higher-level object mapping (OM) libraries for Python, C#/.NET, Node.js, and Java/Spring.

Community-supported clients

The table below shows the recommended third-party client libraries for languages that Redis does not document directly:

Language Client name Github Docs
C++ Boost.Redis https://github.com/boostorg/redis https://www.boost.org/doc/libs/develop/libs/redis/doc/html/index.html
Dart redis_dart_link https://github.com/toolsetlink/redis_dart_link https://github.com/toolsetlink/redis_dart_link
PHP PhpRedis extension https://github.com/phpredis/phpredis https://github.com/phpredis/phpredis/blob/develop/README.md
Ruby redis-rb https://github.com/redis/redis-rb https://rubydoc.info/gems/redis

Requirements

You will need access to a Redis server to use these libraries. You can experiment with a local installation of Redis Open Source (see Install Redis Open Source) or with a free trial of Redis Cloud. To interact with a Redis server without writing code, use the Redis CLI and Redis Insight tools.

Choose a client library for your language

For some languages, we only recommend one client library, but Python, JavaScript, Java, C#, and PHP have multiple options. The sections below summarize the differences between the options for each language.

Python

  • redis-py is the recommended Python client library for most use cases.
  • RedisVL is specialized for handling high-dimensional vector data and is a good choice for AI/ML workflows.
  • RedisOM for Python is an object mapping library that provides a high-level API for working with Redis data structures.

JavaScript

  • node-redis is the recommended JavaScript client library for most use cases.
  • ioredis is an older library that is still supported, but lacks some of the newer features and performance optimizations of node-redis. Note that there is a migration guide available if you are interested in converting your ioredis project to node-redis (see Migrate from ioredis).
  • RedisOM for Node.js is an object mapping library that provides a high-level API for working with Redis data structures.

Java

  • Jedis supports the full feature set of Redis and has a
    straightforward API, but is limited to synchronous operations.
  • Lettuce supports synchronous, asynchronous, and reactive operations. However, it has a more complex API than Jedis and doesn't currently support all Redis features (notably time series and probabilistic data structures).
  • RedisOM for Java is an object mapping library that provides a high-level API for working with Redis data structures.

C#

  • NRedisStack is the recommended C# client library for most use cases.
  • RedisOM for .NET is an object mapping library that provides a high-level API for working with Redis data structures.

PHP

  • Predis is the recommended PHP client library for most use cases. It has "best effort" support from the Redis team (it's a third-party library but the Redis team contributes to it and helps with issues) and has good coverage in the Redis documentation. However, it is implemented in PHP, which limits its performance compared to phpredis, which is implemented in C.
  • phpredis is a popular and well-maintained PHP client library that is implemented using C extensions to PHP for better performance. However, it is not actively supported or documented by the Redis team.

Client library decision tree

Use the decision tree below to help you choose the right client library for your needs, based on the recommendations in the previous sections. Note that you should regard the conclusions as a guideline for your research, not as a definitive answer.

id: client-recommendation
scope: clients
indentWidth: 28
rootQuestion: singleClientLanguageQuestion
questions:
    singleClientLanguageQuestion:
        text: |
            Are you using Go, Rust, C, C++, Dart, or Ruby?
        whyAsk: |
            These languages have only one recommended client library,
            so the choice is straightforward
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: |
                        These languages only have one recommended client library. Use
                        the client library for your language listed in the table above.
                    id: singleClientLanguageOutcome
            no:
                value: "No"
                nextQuestion: multiClientLanguageQuestion

    multiClientLanguageQuestion:
        text: |
            Are you using Python, JavaScript, Java, or C#/.NET
            and require object mapping (ORM-like) functionality?
        whyAsk: |
            RedisOM provides a high-level API for these languages.
            If you don't need OM, we'll help you choose the best low-level client
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: |
                        Use RedisOM for your language
                        (available for Python, JavaScript, Java, and C#/.NET)
                    id: redisOMOutcome
            no:
                value: "No"
                nextQuestion: lowLevelClientQuestion

    lowLevelClientQuestion:
        text: Which language are you using?
        whyAsk: |
            Different languages have different low-level client libraries
            optimized for their ecosystems
        answers:
            python:
                value: Py
                nextQuestion: pythonLowLevelQuestion
            javascript:
                value: JS
                nextQuestion: javascriptLowLevelQuestion
            java:
                value: Java
                nextQuestion: javaLowLevelQuestion
            php:
                value: PHP
                nextQuestion: phpLowLevelQuestion
            dotnet:
                value: "C#"
                outcome:
                    label: Use NRedisStack
                    id: nredisStackOutcome

    pythonLowLevelQuestion:
        text: |
            Are you building an AI/ML application
            mainly based around high-dimensional vector operations?
        whyAsk: |
            RedisVL is specialized for AI/ML workflows with vector data,
            while redis-py is better for general-purpose use
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: Use RedisVL
                    id: redisVLOutcome
            No:
                value: "No"
                outcome:
                    label: Use redis-py
                    id: redisPyOutcome

    javaLowLevelQuestion:
        text: Do you need async or reactive operations?
        whyAsk: |
            Jedis supports only synchronous operations with a simpler API,
            while Lettuce supports async and reactive patterns
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: Use Lettuce
                    id: lettuceOutcome
            no:
                value: "No"
                outcome:
                    label: Use Jedis
                    id: jedisOutcome

    javascriptLowLevelQuestion:
        text: Do you have an existing codebase using ioredis?
        whyAsk: |
            If you're already using ioredis, you can continue with it.
            For new projects, node-redis is the recommended choice
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: |
                        Use ioredis (but see the migration guide if you want to update to node-redis)
                    id: ioredisOutcome
            no:
                value: "No"
                outcome:
                    label: Use node-redis
                    id: nodeRedisOutcome

    phpLowLevelQuestion:
        text: |
            Is maximum performance a higher priority than full support and documentation?
        whyAsk: |
            PhpRedis is a C extension with better performance,
            while Predis is a pure PHP implementation that is better supported and documented
        answers:
            yes:
                value: "Yes"
                outcome:
                    label: Use PhpRedis
                    id: phpredisOutcome
            no:
                value: "No"
                outcome:
                    label: Use Predis
                    id: predisOutcome
RATE THIS PAGE
Back to top ↑